Skip to content

Commit 681a083

Browse files
committed
Update unpacker to always fetch all
When a set of layers are provided to the unpacker, then the unpacker should still fetch them regardless of whether they will be used for unpack. The image handler filters are responsible for removing content which is not intended to be fetched. Currently there is no way to use an unpacker and also fetch all platforms. Signed-off-by: Derek McGowan <[email protected]>
1 parent 2788604 commit 681a083

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

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)