mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
c8d/pull: Same error message for non-matching platform
Use the same error message as the graphdrivers image store backend. It's more informative as it also includes the requested platform and won't break clients checking doing error check with string-matching. Signed-off-by: Paweł Gronowski <pawel.gronowski@docker.com>
This commit is contained in:
@@ -217,6 +217,18 @@ func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platfor
|
||||
}
|
||||
return errdefs.NotFound(fmt.Errorf("pull access denied for %s, repository does not exist or may require 'docker login'", reference.FamiliarName(ref)))
|
||||
}
|
||||
if cerrdefs.IsNotFound(err) {
|
||||
// Transform "no match for platform in manifest" error returned by containerd into
|
||||
// the same message as the graphdrivers backend.
|
||||
// The one returned by containerd doesn't contain the platform and is much less informative.
|
||||
if strings.Contains(err.Error(), "platform") {
|
||||
platformStr := platforms.DefaultString()
|
||||
if platform != nil {
|
||||
platformStr = platforms.Format(*platform)
|
||||
}
|
||||
return errdefs.NotFound(fmt.Errorf("no matching manifest for %s in the manifest list entries: %w", platformStr, err))
|
||||
}
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -208,12 +208,7 @@ func (s *DockerCLIPullSuite) TestPullLinuxImageFailsOnWindows(c *testing.T) {
|
||||
testRequires(c, DaemonIsWindows, Network)
|
||||
_, _, err := dockerCmdWithError("pull", "ubuntu")
|
||||
|
||||
errorMessage := "no matching manifest for windows"
|
||||
if testEnv.UsingSnapshotter() {
|
||||
errorMessage = "no match for platform in manifest"
|
||||
}
|
||||
|
||||
assert.ErrorContains(c, err, errorMessage)
|
||||
assert.ErrorContains(c, err, "no matching manifest for windows")
|
||||
}
|
||||
|
||||
// Regression test for https://github.com/docker/docker/issues/28892
|
||||
@@ -221,10 +216,5 @@ func (s *DockerCLIPullSuite) TestPullWindowsImageFailsOnLinux(c *testing.T) {
|
||||
testRequires(c, DaemonIsLinux, Network)
|
||||
_, _, err := dockerCmdWithError("pull", "mcr.microsoft.com/windows/servercore:ltsc2022")
|
||||
|
||||
errorMessage := "no matching manifest for linux"
|
||||
if testEnv.UsingSnapshotter() {
|
||||
errorMessage = "no match for platform in manifest"
|
||||
}
|
||||
|
||||
assert.ErrorContains(c, err, errorMessage)
|
||||
assert.ErrorContains(c, err, "no matching manifest for linux")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user