Transfer Service: enable remote snapshotters

Signed-off-by: Kohei Tokunaga <ktokunaga.mail@gmail.com>
This commit is contained in:
Kohei Tokunaga
2025-01-06 16:30:11 +09:00
parent 82cb7d4be3
commit 00fee4adb4

View File

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