From 272fed3bb4562c2df9e6e88a263d88ebb112afd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miloslav=20Trma=C4=8D?= Date: Wed, 11 Dec 2019 18:37:41 +0100 Subject: [PATCH] Fix up the wording a bit in various places MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit E.g. - Capitalize log messages - Add a bit more context to the log messages - Don't commit to specific fallback behavior in the API, only say that it may automatically retry. - Fix some typos Signed-off-by: Miloslav Trmač --- image/docker/docker_client.go | 19 ++++++++----------- image/docker/errors.go | 2 +- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/image/docker/docker_client.go b/image/docker/docker_client.go index 740aa36ef1..5a274e2db8 100644 --- a/image/docker/docker_client.go +++ b/image/docker/docker_client.go @@ -411,12 +411,12 @@ func parseRetryAfter(res *http.Response, fallbackDelay time.Duration) time.Durat if after == "" { return fallbackDelay } - logrus.Debugf("detected 'Retry-After' header %q", after) - // First check if we have a numerical value. + logrus.Debugf("Detected 'Retry-After' header %q", after) + // First, check if we have a numerical value. if num, err := strconv.ParseInt(after, 10, 64); err == nil { return time.Duration(num) * time.Second } - // Secondly check if we have an http date. + // Second, check if we have an HTTP date. // If the delta between the date and now is positive, use it. // Otherwise, fall back to using the default exponential back off. if t, err := http.ParseTime(after); err == nil { @@ -424,21 +424,18 @@ func parseRetryAfter(res *http.Response, fallbackDelay time.Duration) time.Durat if delta > 0 { return delta } - logrus.Debugf("negative date: ignoring it") + logrus.Debugf("Retry-After date in the past, ignoring it") return fallbackDelay } - // If the header contains bogus, fall back to using the default - // exponential back off. - logrus.Debugf("invalid format: ignoring it") + // If the header contents are bogus, fall back to using the default exponential back off. + logrus.Debugf("Invalid Retry-After format, ignoring it") return fallbackDelay } // makeRequestToResolvedURL creates and executes a http.Request with the specified parameters, adding authentication and TLS options for the Docker client. // streamLen, if not -1, specifies the length of the data expected on stream. // makeRequest should generally be preferred. -// In case of an http 429 status code in the response, it performs an exponential back off starting at 2 seconds for at most 5 iterations. -// If the `Retry-After` header is set in the response, the specified value or date is -// If the stream is non-nil, no back off will be performed. +// In case of an HTTP 429 status code in the response, it may automatically retry a few times. // TODO(runcom): too many arguments here, use a struct func (c *dockerClient) makeRequestToResolvedURL(ctx context.Context, method, url string, headers map[string][]string, stream io.Reader, streamLen int64, auth sendAuth, extraScope *authScope) (*http.Response, error) { delay := backoffInitialDelay @@ -456,7 +453,7 @@ func (c *dockerClient) makeRequestToResolvedURL(ctx context.Context, method, url if delay > backoffMaxDelay { delay = backoffMaxDelay } - logrus.Debugf("too many request to %s: sleeping for %f seconds before next attempt", url, delay.Seconds()) + logrus.Debugf("Too many requests to %s: sleeping for %f seconds before next attempt", url, delay.Seconds()) select { case <-ctx.Done(): return nil, ctx.Err() diff --git a/image/docker/errors.go b/image/docker/errors.go index afe7ada80a..f626cc7da9 100644 --- a/image/docker/errors.go +++ b/image/docker/errors.go @@ -14,7 +14,7 @@ var ( // docker V1 registry. ErrV1NotSupported = errors.New("can't talk to a V1 docker registry") // ErrTooManyRequests is returned when the status code returned is 429 - ErrTooManyRequests = errors.New("too many request to registry") + ErrTooManyRequests = errors.New("too many requests to registry") ) // ErrUnauthorizedForCredentials is returned when the status code returned is 401