diff options
author | Sebastiaan van Stijn <github@gone.nl> | 2020-12-07 16:09:05 +0100 |
---|---|---|
committer | Sebastiaan van Stijn <github@gone.nl> | 2021-02-23 09:49:51 +0100 |
commit | 80cc1f1d6fb1d03014f7ef5d3a1e216538ddb855 (patch) | |
tree | ef667e257dde0f7925191aca57ee0f4d53ea5f5b /registry/service.go | |
parent | 588da41f528e674e4bc9cf064b01e1c4447de517 (diff) | |
download | docker-80cc1f1d6fb1d03014f7ef5d3a1e216538ddb855.tar.gz |
registry.Auth: try next endpoints on non-auth failures
Allow falling back to non-TLS endpoints if present.
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Diffstat (limited to 'registry/service.go')
-rw-r--r-- | registry/service.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/registry/service.go b/registry/service.go index 37f6ed51fd..7e55923c11 100644 --- a/registry/service.go +++ b/registry/service.go @@ -131,7 +131,15 @@ func (s *DefaultService) Auth(ctx context.Context, authConfig *types.AuthConfig, } for _, endpoint := range endpoints { - return loginV2(authConfig, endpoint, userAgent) + status, token, err = loginV2(authConfig, endpoint, userAgent) + if err == nil { + return + } + if errdefs.IsUnauthorized(err) { + // Failed to authenticate; don't continue with (non-TLS) endpoints. + return status, token, err + } + logrus.WithError(err).Infof("Error logging in to endpoint, trying next endpoint") } return "", "", err |