Merge pull request #18839 from aaronlehmann/v1-fallback-404

When a manifest is not found, allow fallback to v1
Upstream-commit: 95b708cf19f24dcf0044f2f4e96db2579201cbeb
Component: engine
This commit is contained in:
David Calavera
2015-12-23 10:01:39 -08:00
4 changed files with 38 additions and 5 deletions
@@ -228,3 +228,15 @@ func (s *DockerRegistrySuite) TestPullIDStability(c *check.C) {
c.Fatalf("expected %s; got %s", derivedImage, out)
}
}
// TestPullFallbackOn404 tries to pull a nonexistent manifest and confirms that
// the pull falls back to the v1 protocol.
//
// Ref: docker/docker#18832
func (s *DockerRegistrySuite) TestPullFallbackOn404(c *check.C) {
repoName := fmt.Sprintf("%v/does/not/exist", privateRegistryURL)
out, _, _ := dockerCmdWithError("pull", repoName)
c.Assert(out, checker.Contains, "v1 ping attempt")
}
@@ -1,6 +1,7 @@
package main
import (
"fmt"
"regexp"
"strings"
"time"
@@ -53,8 +54,10 @@ func (s *DockerHubPullSuite) TestPullNonExistingImage(c *check.C) {
} {
out, err := s.CmdWithError("pull", e.Alias)
c.Assert(err, checker.NotNil, check.Commentf("expected non-zero exit status when pulling non-existing image: %s", out))
// Hub returns 401 rather than 404 for nonexistent library/ repos.
c.Assert(out, checker.Contains, "unauthorized: access to the requested resource is not authorized", check.Commentf("expected unauthorized error message"))
// Hub returns 401 rather than 404 for nonexistent repos over
// the v2 protocol - but we should end up falling back to v1,
// which does return a 404.
c.Assert(out, checker.Contains, fmt.Sprintf("Error: image %s not found", e.Repo), check.Commentf("expected image not found error messages"))
}
}