summaryrefslogtreecommitdiff
path: root/registry/registry.go
diff options
context:
space:
mode:
authorAaron Lehmann <aaron.lehmann@docker.com>2015-12-21 15:42:04 -0800
committerAaron Lehmann <aaron.lehmann@docker.com>2015-12-21 18:19:38 -0800
commit9d6acbee92016c47796ee8751dce9c59056f850d (patch)
tree79af2eb8d59a77df84b468e521c9a24c7e66e2f1 /registry/registry.go
parent312c82677bdc86d50b483d642ad8c61f1c840c55 (diff)
downloaddocker-9d6acbee92016c47796ee8751dce9c59056f850d.tar.gz
When a manifest is not found, allow fallback to v1
PR #18590 caused compatibility issues with registries such as gcr.io which support both the v1 and v2 protocols, but do not provide the same set of images over both protocols. After #18590, pulls from these registries would never use the v1 protocol, because of the Docker-Distribution-Api-Version header indicating that v2 was supported. Fix the problem by making an exception for the case where a manifest is not found. This should allow fallback to v1 in case that image is exposed over the v1 protocol but not the v2 protocol. This avoids the overly aggressive fallback behavior before #18590 which would allow protocol fallback after almost any error, but restores interoperability with mixed v1/v2 registry setups. Fixes #18832 Signed-off-by: Aaron Lehmann <aaron.lehmann@docker.com>
Diffstat (limited to 'registry/registry.go')
-rw-r--r--registry/registry.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/registry/registry.go b/registry/registry.go
index fc2959a5d5..ba1626c137 100644
--- a/registry/registry.go
+++ b/registry/registry.go
@@ -188,8 +188,8 @@ func addRequiredHeadersToRedirectedRequests(req *http.Request, via []*http.Reque
return nil
}
-func shouldV2Fallback(err errcode.Error) bool {
- logrus.Debugf("v2 error: %T %v", err, err)
+// ShouldV2Fallback returns true if this error is a reason to fall back to v1.
+func ShouldV2Fallback(err errcode.Error) bool {
switch err.Code {
case errcode.ErrorCodeUnauthorized, v2.ErrorCodeManifestUnknown:
return true
@@ -220,7 +220,7 @@ func ContinueOnError(err error) bool {
case ErrNoSupport:
return ContinueOnError(v.Err)
case errcode.Error:
- return shouldV2Fallback(v)
+ return ShouldV2Fallback(v)
case *client.UnexpectedHTTPResponseError:
return true
case error: