@@ -22,6 +22,7 @@ import (
2222
2323 "github.com/containerd/errdefs"
2424 "github.com/containerd/log"
25+ "github.com/containerd/platforms"
2526 ocispec "github.com/opencontainers/image-spec/specs-go/v1"
2627
2728 "github.com/containerd/containerd/v2/core/content"
@@ -194,12 +195,17 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch
194195 enableRemoteSnapshotAnnotations := false
195196 // Only unpack if requested unpackconfig matches default/supported unpackconfigs
196197 for _ , u := range unpacks {
197- matched , mu := getSupportedPlatform (u , ts .config .UnpackPlatforms )
198+ matched , mu := getSupportedPlatform (ctx , u , ts .config .UnpackPlatforms )
198199 if matched {
199200 if v , ok := mu .SnapshotterExports ["enable_remote_snapshot_annotations" ]; ok && v == "true" {
200201 enableRemoteSnapshotAnnotations = true
201202 }
202203 uopts = append (uopts , unpack .WithUnpackPlatform (mu ))
204+ } else {
205+ log .G (ctx ).WithFields (log.Fields {
206+ "platform" : platforms .FormatAll (u .Platform ),
207+ "snapshotter" : u .Snapshotter ,
208+ }).Warn ("Unpack configuration not supported, skipping" )
203209 }
204210 }
205211
@@ -288,8 +294,7 @@ func fetchHandler(ingester content.Ingester, fetcher remotes.Fetcher, pt *Progre
288294
289295// getSupportedPlatform returns a matched platform comparing input UnpackConfiguration to the supported platform/snapshotter combinations
290296// If input platform didn't specify snapshotter, default will be used if there is a match on platform.
291- func getSupportedPlatform (uc transfer.UnpackConfiguration , supportedPlatforms []unpack.Platform ) (bool , unpack.Platform ) {
292- var u unpack.Platform
297+ func getSupportedPlatform (ctx context.Context , uc transfer.UnpackConfiguration , supportedPlatforms []unpack.Platform ) (matched bool , u unpack.Platform ) {
293298 for _ , sp := range supportedPlatforms {
294299 // If both platform and snapshotter match, return the supportPlatform
295300 // If platform matched and SnapshotterKey is empty, we assume client didn't pass SnapshotterKey
@@ -298,10 +303,23 @@ func getSupportedPlatform(uc transfer.UnpackConfiguration, supportedPlatforms []
298303 // Assume sp.SnapshotterKey is not empty
299304 if uc .Snapshotter == sp .SnapshotterKey {
300305 return true , sp
301- } else if uc .Snapshotter == "" && sp .SnapshotterKey == defaults .DefaultSnapshotter {
302- return true , sp
306+ } else if uc .Snapshotter == "" {
307+ if sp .SnapshotterKey == defaults .DefaultSnapshotter {
308+ // Return as best match immediately
309+ return true , sp
310+ } else if ! matched {
311+ // Match but prefer default if present to prevent configuration
312+ // changes from altering default behavior
313+ matched = true
314+ u = sp
315+ }
303316 }
317+ } else if uc .Snapshotter == sp .SnapshotterKey {
318+ log .G (ctx ).WithFields (log.Fields {
319+ "platform" : platforms .FormatAll (uc .Platform ),
320+ "snapshotter" : uc .Snapshotter ,
321+ }).Info ("Found unpack with matching snapshotter but platform does not match" )
304322 }
305323 }
306- return false , u
324+ return
307325}
0 commit comments