@@ -30,6 +30,7 @@ import (
30
30
"github.com/containerd/containerd/platforms"
31
31
refdocker "github.com/containerd/containerd/reference/docker"
32
32
"github.com/containerd/containerd/remotes"
33
+ "github.com/containerd/containerd/snapshots"
33
34
"github.com/containerd/imgcrypt"
34
35
"github.com/containerd/imgcrypt/images/encryption"
35
36
"github.com/containerd/nerdctl/pkg/idutil/imagewalker"
@@ -47,7 +48,7 @@ type EnsuredImage struct {
47
48
Image containerd.Image
48
49
ImageConfig ocispec.ImageConfig
49
50
Snapshotter string
50
- Remote bool // true for stargz
51
+ Remote bool // true for stargz or overlaybd
51
52
}
52
53
53
54
// PullMode is either one of "always", "missing", "never"
@@ -74,7 +75,7 @@ func GetExistingImage(ctx context.Context, client *containerd.Client, snapshotte
74
75
Image : image ,
75
76
ImageConfig : * imgConfig ,
76
77
Snapshotter : snapshotter ,
77
- Remote : isStargz (snapshotter ),
78
+ Remote : isStargz (snapshotter ) || isOverlaybd ( snapshotter ) ,
78
79
}
79
80
if unpacked , err := image .IsUnpacked (ctx , snapshotter ); err == nil && ! unpacked {
80
81
if err := image .Unpack (ctx , snapshotter ); err != nil {
@@ -107,7 +108,6 @@ func EnsureImage(ctx context.Context, client *containerd.Client, stdout, stderr
107
108
default :
108
109
return nil , fmt .Errorf ("unexpected pull mode: %q" , mode )
109
110
}
110
-
111
111
if mode != "always" && len (ocispecPlatforms ) == 1 {
112
112
res , err := GetExistingImage (ctx , client , snapshotter , rawRef , ocispecPlatforms [0 ])
113
113
if err == nil {
@@ -198,14 +198,13 @@ func PullImage(ctx context.Context, client *containerd.Client, stdout, stderr io
198
198
unpackB = len (ocispecPlatforms ) == 1
199
199
}
200
200
201
- var sgz bool
201
+ var sgz , overlaybd bool
202
202
if unpackB {
203
203
logrus .Debugf ("The image will be unpacked for platform %q, snapshotter %q." , ocispecPlatforms [0 ], snapshotter )
204
204
imgcryptPayload := imgcrypt.Payload {}
205
205
imgcryptUnpackOpt := encryption .WithUnpackConfigApplyOpts (encryption .WithDecryptedUnpack (& imgcryptPayload ))
206
206
config .RemoteOpts = append (config .RemoteOpts ,
207
207
containerd .WithPullUnpack ,
208
- containerd .WithPullSnapshotter (snapshotter ),
209
208
containerd .WithUnpackOpts ([]containerd.UnpackOpt {imgcryptUnpackOpt }))
210
209
211
210
sgz = isStargz (snapshotter )
@@ -216,6 +215,20 @@ func PullImage(ctx context.Context, client *containerd.Client, stdout, stderr io
216
215
containerd .WithImageHandlerWrapper (source .AppendDefaultLabelsHandlerWrapper (ref , 10 * 1024 * 1024 )),
217
216
)
218
217
}
218
+ overlaybd = isOverlaybd (snapshotter )
219
+ if overlaybd {
220
+ snlabel := map [string ]string {"containerd.io/snapshot/image-ref" : ref }
221
+ logrus .Debugf ("append remote opts: %s" , snlabel )
222
+
223
+ config .RemoteOpts = append (
224
+ config .RemoteOpts ,
225
+ containerd .WithPullSnapshotter (snapshotter , snapshots .WithLabels (snlabel )),
226
+ )
227
+ } else {
228
+ config .RemoteOpts = append (
229
+ config .RemoteOpts ,
230
+ containerd .WithPullSnapshotter (snapshotter ))
231
+ }
219
232
} else {
220
233
logrus .Debugf ("The image will not be unpacked. Platforms=%v." , ocispecPlatforms )
221
234
}
@@ -232,7 +245,7 @@ func PullImage(ctx context.Context, client *containerd.Client, stdout, stderr io
232
245
Image : containerdImage ,
233
246
ImageConfig : * imgConfig ,
234
247
Snapshotter : snapshotter ,
235
- Remote : sgz ,
248
+ Remote : ( sgz || overlaybd ) ,
236
249
}
237
250
return res , nil
238
251
@@ -248,6 +261,10 @@ func isStargz(sn string) bool {
248
261
return true
249
262
}
250
263
264
+ func isOverlaybd (sn string ) bool {
265
+ return sn == "overlaybd"
266
+ }
267
+
251
268
func getImageConfig (ctx context.Context , image containerd.Image ) (* ocispec.ImageConfig , error ) {
252
269
desc , err := image .Config (ctx )
253
270
if err != nil {
0 commit comments