Skip to content

Commit 29a6ab8

Browse files
author
Maksym Pavlenko
authored
Merge pull request containerd#10202 from dmcgowan/unpack-fetch-all
Unpack fetch all
2 parents 76895c4 + 681a083 commit 29a6ab8

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

cmd/ctr/commands/images/pull.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -106,20 +106,20 @@ command. As part of this process, we do the following:
106106
}
107107

108108
var sopts []image.StoreOpt
109+
p, err := platforms.ParseAll(context.StringSlice("platform"))
110+
if err != nil {
111+
return err
112+
}
113+
114+
// Set unpack configuration
115+
for _, platform := range p {
116+
sopts = append(sopts, image.WithUnpack(platform, context.String("snapshotter")))
117+
}
109118
if !context.Bool("all-platforms") {
110-
p, err := platforms.ParseAll(context.StringSlice("platform"))
111-
if err != nil {
112-
return err
113-
}
114119
if len(p) == 0 {
115120
p = append(p, platforms.DefaultSpec())
116121
}
117122
sopts = append(sopts, image.WithPlatforms(p...))
118-
119-
// Set unpack configuration
120-
for _, platform := range p {
121-
sopts = append(sopts, image.WithUnpack(platform, context.String("snapshotter")))
122-
}
123123
}
124124
// TODO: Support unpack for all platforms..?
125125
// Pass in a *?

core/unpack/unpacker.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,8 @@ func (u *Unpacker) unpack(
262262
}
263263

264264
if unpack == nil {
265-
return fmt.Errorf("unpacker does not support platform %s for image %s", imgPlatform, config.Digest)
265+
log.G(ctx).WithField("image", config.Digest).WithField("platform", platforms.Format(imgPlatform)).Debugf("unpacker does not support platform, only fetching layers")
266+
return u.fetch(ctx, h, layers, nil)
266267
}
267268

268269
atomic.AddInt32(&u.unpacks, 1)
@@ -460,12 +461,18 @@ func (u *Unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec
460461
tracing.Attribute("layer.media.digest", desc.Digest.String()),
461462
)
462463
desc := desc
463-
i := i
464+
var ch chan struct{}
465+
if done != nil {
466+
ch = done[i]
467+
}
468+
464469
if err := u.acquire(ctx); err != nil {
465470
return err
466471
}
467472

468473
eg.Go(func() error {
474+
defer layerSpan.End()
475+
469476
unlock, err := u.lockBlobDescriptor(ctx2, desc)
470477
if err != nil {
471478
u.release()
@@ -480,11 +487,12 @@ func (u *Unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec
480487
if err != nil && !errors.Is(err, images.ErrSkipDesc) {
481488
return err
482489
}
483-
close(done[i])
490+
if ch != nil {
491+
close(ch)
492+
}
484493

485494
return nil
486495
})
487-
layerSpan.End()
488496
}
489497

490498
return eg.Wait()

0 commit comments

Comments
 (0)