Преглед изворни кода

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>
Sebastiaan van Stijn пре 4 година
родитељ
комит
80cc1f1d6f
1 измењених фајлова са 9 додато и 1 уклоњено
  1. 9 1
      registry/service.go

+ 9 - 1
registry/service.go

@@ -131,7 +131,15 @@ func (s *DefaultService) Auth(ctx context.Context, authConfig *types.AuthConfig,
 	}
 	}
 
 
 	for _, endpoint := range endpoints {
 	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
 	return "", "", err