Skip to content

Commit 32b594f

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]> (cherry picked from commit 681a083) Signed-off-by: Derek McGowan <[email protected]>
1 parent 36bbb4d commit 32b594f

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

pkg/unpack/unpacker.go

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

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

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

469474
eg.Go(func() error {
475+
defer layerSpan.End()
476+
470477
unlock, err := u.lockBlobDescriptor(ctx2, desc)
471478
if err != nil {
472479
u.release()
@@ -481,11 +488,12 @@ func (u *Unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec
481488
if err != nil && !errors.Is(err, images.ErrSkipDesc) {
482489
return err
483490
}
484-
close(done[i])
491+
if ch != nil {
492+
close(ch)
493+
}
485494

486495
return nil
487496
})
488-
layerSpan.End()
489497
}
490498

491499
return eg.Wait()

0 commit comments

Comments
 (0)