From d98515d91dc547038d29682aac11ac3922b50e4b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Gronowski?= Date: Wed, 17 Jun 2026 22:07:38 +0200 Subject: [PATCH] c8d/pull: Apply host platform variant to pulls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Always pass the pull platform through WithPlatform. For implicit pulls this is the host platform, including the amd64 variant; for explicit pulls it remains the requested platform. This doesn't make the platform matching strict - containerd resolves WithPlatform through platforms.Only, so linux/amd64/v3 still falls back to compatible lower or plain linux/amd64 manifests when no v3 manifest exists. This keeps initial pull selection consistent with store-side matching and preserves compatibility with non-variant amd64 images. Signed-off-by: Paweł Gronowski --- daemon/containerd/image_pull.go | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/daemon/containerd/image_pull.go b/daemon/containerd/image_pull.go index 545e3b5aa6..4adc499ffd 100644 --- a/daemon/containerd/image_pull.go +++ b/daemon/containerd/image_pull.go @@ -104,10 +104,11 @@ func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platfor ctx = remotes.WithMediaTypeKeyPrefix(ctx, policyimage.ArtifactTypeCosignSignature, "cosign-signature") ctx = remotes.WithMediaTypeKeyPrefix(ctx, policyimage.ArtifactTypeSigstoreBundle, "sigstore-bundle") - var opts []containerd.RemoteOpt + pullPlatform := i.hostPlatformSpec() if platform != nil { - opts = append(opts, containerd.WithPlatform(platforms.FormatAll(*platform))) + pullPlatform = *platform } + opts := []containerd.RemoteOpt{containerd.WithPlatform(platforms.FormatAll(pullPlatform))} resolver, _ := i.newResolverFromAuthConfig(ctx, authConfig, ref, metaHeaders) opts = append(opts, containerd.WithResolver(resolver)) @@ -138,10 +139,7 @@ func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platfor }() } - p := i.hostPlatformMatcher() - if platform != nil { - p = platforms.Only(*platform) - } + p := platforms.Only(pullPlatform) pullJobs := newJobs() opts = append(opts, containerd.WithImageHandler(c8dimages.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { @@ -252,10 +250,7 @@ func (i *ImageService) pullTag(ctx context.Context, ref reference.Named, platfor // 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.FormatAll(i.hostPlatformSpec()) - if platform != nil { - platformStr = platforms.FormatAll(*platform) - } + platformStr := platforms.FormatAll(pullPlatform) return errdefs.NotFound(fmt.Errorf("no matching manifest for %s in the manifest list entries: %w", platformStr, err)) } }