Skip to content

c8d/pull: Same error message for non-matching platform#48414

Merged
vvoland merged 1 commit intomoby:masterfrom
vvoland:c8d-pull-msg
Sep 2, 2024
Merged

c8d/pull: Same error message for non-matching platform#48414
vvoland merged 1 commit intomoby:masterfrom
vvoland:c8d-pull-msg

Conversation

@vvoland
Copy link
Contributor

@vvoland vvoland commented Sep 2, 2024

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.

- What I did

- How I did it

- How to verify it
CI

- Description for the changelog

containerd image store: Improve `docker pull` error message when the image platform doesn't match 

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

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>
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

// 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") {
Copy link
Member

Choose a reason for hiding this comment

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

😢 on the string-matching. Guess we have no real other option here 😞

Wondering if there would be options to do so through richer errors from the containerd code 🤔 (or perhaps the containerd code to return a better error-message)

Copy link
Member

Choose a reason for hiding this comment

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

Went looking if that's something the matcher could return, but that's using a simple bool as interface, so no options there 😢

// Matcher matches platforms specifications, provided by an image or runtime.
type Matcher interface {
Match(platform specs.Platform) bool
}

// 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()
Copy link
Member

Choose a reason for hiding this comment

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

Just a note; this also includes the os-version on Windows. I don't think we show that in other places, but perhaps it's good to show, as we would be matching using that (I think?)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, IMO it makes sense to show it. Although it will only really be matched on the windows host due to different containerd platform matcher implementation based on the target platform the code was built for.

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))
Copy link
Member

Choose a reason for hiding this comment

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

FWIW, I'd be somewhat ok with changing this to no match for platform <platform> as it's probably more user-friendly, but yeah, not sure if anyone is expecting this error message 🤔

@vvoland vvoland merged commit 0473cfa into moby:master Sep 2, 2024
@thaJeztah thaJeztah added the containerd-integration Issues and PRs related to containerd integration label Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/images Image Distribution area/ux containerd-integration Issues and PRs related to containerd integration process/cherry-picked status/2-code-review

Projects

Development

Successfully merging this pull request may close these issues.

2 participants