-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Print error for failed HTTP auth request. #1249
Conversation
Signed-off-by: Kenny Leung <kleung@google.com>
Code LGTM. @k4leung4 Any tests for this? |
@@ -240,7 +240,8 @@ func (th *tokenHandler) fetchToken(params map[string]string) (token *tokenRespon | |||
defer resp.Body.Close() | |||
|
|||
if !client.SuccessStatus(resp.StatusCode) { | |||
return nil, fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode)) | |||
err := client.HandleErrorResponse(resp) | |||
return nil, fmt.Errorf("token auth attempt for registry: %s request failed with status: %d %s: %q", req.URL, resp.StatusCode, http.StatusText(resp.StatusCode), err) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems odd to throw away a nicely typed error for a formatted string here. Perhaps any additional messaging about failure to fetch a token should be left to the caller.
FYI, he's on vacation this week. I will ping him Monday. :) |
Thanks @mattmoor |
Signed-off-by: Kenny Leung <kleung@google.com>
…ution into print-error-msg Changed to use typed error instead of formatted string. Added tests for new public method. Signed-off-by: Kenny Leung <kleung@google.com>
Changed to make use of typed error instead of formatted string. please take another look. |
Current coverage is
|
LGTM |
Anything left needed to merge this? I ask in part because of the upcoming code freeze. |
LGTM |
CI is back, lets turn this green then merge 😉 |
Print error for failed HTTP auth request.
distribution#1249 changed token fetching to parse HTTP error response bodies as serialized errcodes. However, Docker Hub's authentication endpoint does not return error bodies in this format. To work around this, convert its format into ErrCodeUnauthorized or ErrCodeUnknown. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
distribution#1249 changed token fetching to parse HTTP error response bodies as serialized errcodes. However, Docker Hub's authentication endpoint does not return error bodies in this format. To work around this, convert its format into ErrCodeUnauthorized or ErrCodeUnknown. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Print error for failed HTTP auth request.
distribution#1249 changed token fetching to parse HTTP error response bodies as serialized errcodes. However, Docker Hub's authentication endpoint does not return error bodies in this format. To work around this, convert its format into ErrCodeUnauthorized or ErrCodeUnknown. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Print error for failed HTTP auth request.
distribution#1249 changed token fetching to parse HTTP error response bodies as serialized errcodes. However, Docker Hub's authentication endpoint does not return error bodies in this format. To work around this, convert its format into ErrCodeUnauthorized or ErrCodeUnknown. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
distribution#1249 changed token fetching to parse HTTP error response bodies as serialized errcodes. However, Docker Hub's authentication endpoint does not return error bodies in this format. To work around this, convert its format into ErrCodeUnauthorized or ErrCodeUnknown. Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
In the case of a failed HTTP auth token request, in addition to the current message that is returned, also return the error message in the response. This is to provide the user with a more descriptive message about what went wrong.
Signed-off-by: Kenny Leung kleung@google.com