From 00fee4adb45f012c83961087b4c8be52c1f1c93d Mon Sep 17 00:00:00 2001 From: Kohei Tokunaga Date: Mon, 6 Jan 2025 16:30:11 +0900 Subject: [PATCH] Transfer Service: enable remote snapshotters Signed-off-by: Kohei Tokunaga --- core/transfer/local/pull.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/core/transfer/local/pull.go b/core/transfer/local/pull.go index 221aba7b11..8c9ab2c870 100644 --- a/core/transfer/local/pull.go +++ b/core/transfer/local/pull.go @@ -31,6 +31,7 @@ import ( "github.com/containerd/containerd/v2/core/transfer" "github.com/containerd/containerd/v2/core/unpack" "github.com/containerd/containerd/v2/defaults" + snpkg "github.com/containerd/containerd/v2/pkg/snapshotters" ) func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetcher, is transfer.ImageStorer, tops *transfer.Config) error { @@ -183,10 +184,14 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch unpacks := iu.UnpackPlatforms() if len(unpacks) > 0 { uopts := []unpack.UnpackerOpt{} + enableRemoteSnapshotAnnotations := false // Only unpack if requested unpackconfig matches default/supported unpackconfigs for _, u := range unpacks { matched, mu := getSupportedPlatform(u, ts.config.UnpackPlatforms) if matched { + if v, ok := mu.SnapshotterExports["enable_remote_snapshot_annotations"]; ok && v == "true" { + enableRemoteSnapshotAnnotations = true + } uopts = append(uopts, unpack.WithUnpackPlatform(mu)) } } @@ -199,6 +204,10 @@ func (ts *localTransferService) pull(ctx context.Context, ir transfer.ImageFetch uopts = append(uopts, unpack.WithDuplicationSuppressor(ts.config.DuplicationSuppressor)) } + if enableRemoteSnapshotAnnotations { + handler = snpkg.AppendInfoHandlerWrapper(name)(handler) + } + unpacker, err = unpack.NewUnpacker(ctx, ts.content, uopts...) if err != nil { return fmt.Errorf("unable to initialize unpacker: %w", err)