@@ -29,6 +29,7 @@ import (
29
29
30
30
containerd "github.com/containerd/containerd/v2/client"
31
31
"github.com/containerd/containerd/v2/core/content"
32
+ "github.com/containerd/containerd/v2/core/diff"
32
33
"github.com/containerd/containerd/v2/core/images"
33
34
"github.com/containerd/containerd/v2/core/remotes"
34
35
"github.com/containerd/containerd/v2/core/snapshots"
@@ -59,7 +60,7 @@ type EnsuredImage struct {
59
60
type PullMode = string
60
61
61
62
// GetExistingImage returns the specified image if exists in containerd. Return errdefs.NotFound() if not exists.
62
- func GetExistingImage (ctx context.Context , client * containerd.Client , snapshotter , rawRef string , platform ocispec.Platform ) (* EnsuredImage , error ) {
63
+ func GetExistingImage (ctx context.Context , client * containerd.Client , snapshotter string , syncfs bool , rawRef string , platform ocispec.Platform ) (* EnsuredImage , error ) {
63
64
var res * EnsuredImage
64
65
imgwalker := & imagewalker.ImageWalker {
65
66
Client : client ,
@@ -82,7 +83,7 @@ func GetExistingImage(ctx context.Context, client *containerd.Client, snapshotte
82
83
Remote : getSnapshotterOpts (snapshotter ).isRemote (),
83
84
}
84
85
if unpacked , err := image .IsUnpacked (ctx , snapshotter ); err == nil && ! unpacked {
85
- if err := image .Unpack (ctx , snapshotter ); err != nil {
86
+ if err := image .Unpack (ctx , snapshotter , containerd . WithUnpackApplyOpts ( diff . WithSyncFs ( syncfs )) ); err != nil {
86
87
return err
87
88
}
88
89
}
@@ -115,7 +116,7 @@ func EnsureImage(ctx context.Context, client *containerd.Client, rawRef string,
115
116
116
117
// if not `always` pull and given one platform and image found locally, return existing image directly.
117
118
if options .Mode != "always" && len (options .OCISpecPlatform ) == 1 {
118
- if res , err := GetExistingImage (ctx , client , options .GOptions .Snapshotter , rawRef , options .OCISpecPlatform [0 ]); err == nil {
119
+ if res , err := GetExistingImage (ctx , client , options .GOptions .Snapshotter , options . SyncFs , rawRef , options .OCISpecPlatform [0 ]); err == nil {
119
120
return res , nil
120
121
} else if ! errdefs .IsNotFound (err ) {
121
122
return nil , err
@@ -204,6 +205,7 @@ func PullImage(ctx context.Context, client *containerd.Client, resolver remotes.
204
205
Resolver : resolver ,
205
206
RemoteOpts : []containerd.RemoteOpt {},
206
207
Platforms : options .OCISpecPlatform , // empty for all-platforms
208
+ SyncFs : options .SyncFs ,
207
209
}
208
210
if ! options .Quiet {
209
211
config .ProgressOutput = options .Stderr
0 commit comments