Skip to content

Conversation

rumpl
Copy link
Member

@rumpl rumpl commented Sep 20, 2023

- What I did

moby and containerd have slightly different error messages when someone tries to pull an image that doesn't contain the current platform, instead of looking inside the error returned by containerd we match the errors in the test related to what image backend we are using

- How I did it

- How to verify it

- Description for the changelog

- A picture of a cute animal (not mandatory but encouraged)

moby and containerd have slightly different error messages when someone
tries to pull an image that doesn't contain the current platform,
instead of looking inside the error returned by containerd we match the
errors in the test related to what image backend we are using

Signed-off-by: Djordje Lukic <djordje.lukic@docker.com>
@rumpl rumpl added area/distribution Image Distribution status/2-code-review area/testing area/images Image Distribution containerd-integration Issues and PRs related to containerd integration labels Sep 20, 2023
@rumpl rumpl added this to the 25.0.0 milestone Sep 20, 2023
Copy link
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"LGTM" (to fix this specific test), but also went looking a bit further; left a comment 😅

@@ -285,5 +285,11 @@ func (s *DockerCLIPullSuite) TestPullLinuxImageFailsOnWindows(c *testing.T) {
func (s *DockerCLIPullSuite) TestPullWindowsImageFailsOnLinux(c *testing.T) {
testRequires(c, DaemonIsLinux, Network)
_, _, err := dockerCmdWithError("pull", "mcr.microsoft.com/windows/servercore:ltsc2022")
assert.ErrorContains(c, err, "no matching manifest for linux")

errorMessage := "no matching manifest for linux"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We probably need to update the test above as well; it currently doesn't fail because we don't run the Windows tests with snapshotters 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also thinking of some things to consider; honestly, the containerd error is less informative than the old one, because it doesn't show WHAT we weren't able to match (which could be obvious if a user explicitly passed a --platform, but less so if not, but could also be that user passed a partial platform, and we normalized it).

The "non-snapshotter" error looks to be this one;

type noMatchesErr struct {
platform ocispec.Platform
}
func (e noMatchesErr) Error() string {
return fmt.Sprintf("no matching manifest for %s in the manifest list entries", formatPlatform(e.platform))
}

For containerd, the error is produced here;

if len(children) == 0 {
return children, fmt.Errorf("no match for platform in manifest: %w", errdefs.ErrNotFound)
}

I guess ideally the containerd error would be somewhat more informative (what were we trying to match, and couldn't find?), but it looks like that's less trivial, because that's fully up to the HandlerFunc that's passed (which does the filtering).

The alternative here would be to handle this on our side: when we get the result. The error returned is typed; it's a errdefs.ErrNotFound, so we can decorate the error (and perhaps we can decorate it regardless of what the reason was), i.e.;

if cerrdefs.IsNotFound(err) {
    err = fmt.Errorf("no matching manifest for %s: %w", formatPlatform(e.platform), err)
} else {
    err = fmt.Errorf("failed to find matching manifest for %s: %w", formatPlatform(e.platform), err)
}

(I removed "in the manifest list entries" from the above, but maybe we should keep it, not sure if it's "too much")

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/distribution Image Distribution area/images Image Distribution area/testing containerd-integration Issues and PRs related to containerd integration status/2-code-review
Projects
Development

Successfully merging this pull request may close these issues.

3 participants