Skip to content
This repository has been archived by the owner on Nov 1, 2022. It is now read-only.

don't log errors that were caused by a context timeout #688

Merged
merged 1 commit into from
Aug 24, 2017

Conversation

philwinder
Copy link
Contributor

@philwinder philwinder commented Aug 4, 2017

For each image fetch (including tags and all manifests) is limited by a context deadline of 10s. After this all remaining http requests will return an i/o timeout type error.

We wish to allow time for the other images to go and fetch their stuff, so it was recommended that we just suppress this error and re-request the unfetched manifests on a subsequent warm.

@@ -141,9 +141,11 @@ func (w *Warmer) warm(id flux.ImageID, creds Credentials) {
// Get the image from the remote
img, err := client.Manifest(imageID)
if err != nil {
if !strings.Contains(err.Error(), context.DeadlineExceeded.Error()) && !strings.Contains(err.Error(), "net/http: request canceled") {
w.Logger.Log("err", errors.Wrap(err, "requesting manifests"))
if err, ok := errors.Cause(err).(net.Error); ok && err.Timeout() {

This comment was marked as abuse.

This comment was marked as abuse.

squaremo
squaremo previously approved these changes Aug 9, 2017
Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this changes behaviour. But on the basis that it's a neater test for the kind of error, why not :)

@squaremo squaremo dismissed their stale review August 10, 2017 10:04

Thought of a possible way to improve on this

Copy link
Member

@squaremo squaremo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we are setting a deadline for the fetches to complete. In light of that, I think it'd be better to construct a context with context.WithDeadline(...), and use that to do all the fetching etc. The error can then be directly compared to context.DeadlineExceeded to see if we care about logging it.

@@ -141,9 +141,11 @@ func (w *Warmer) warm(id flux.ImageID, creds Credentials) {
// Get the image from the remote
img, err := client.Manifest(imageID)
if err != nil {
if !strings.Contains(err.Error(), context.DeadlineExceeded.Error()) && !strings.Contains(err.Error(), "net/http: request canceled") {
w.Logger.Log("err", errors.Wrap(err, "requesting manifests"))
if err, ok := errors.Cause(err).(net.Error); ok && err.Timeout() {

This comment was marked as abuse.

@squaremo
Copy link
Member

This PR is an advance on what we have -- it tests for the correct kind of error to suppress. I have logged the issue #713 for replacing our use of context timeouts with a deadline.

@philwinder philwinder merged commit c7fd6fa into master Aug 24, 2017
@philwinder philwinder deleted the ignore-context-timeouts branch August 24, 2017 08:30
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants