Skip to content

Commit

Permalink
Update unpacker to always fetch all
Browse files Browse the repository at this point in the history
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 <derek@mcg.dev>
  • Loading branch information
dmcgowan committed May 10, 2024
1 parent 2788604 commit 681a083
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions core/unpack/unpacker.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@ func (u *Unpacker) unpack(
}

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

atomic.AddInt32(&u.unpacks, 1)
Expand Down Expand Up @@ -460,12 +461,18 @@ func (u *Unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec
tracing.Attribute("layer.media.digest", desc.Digest.String()),
)
desc := desc
i := i
var ch chan struct{}
if done != nil {
ch = done[i]
}

if err := u.acquire(ctx); err != nil {
return err
}

eg.Go(func() error {
defer layerSpan.End()

unlock, err := u.lockBlobDescriptor(ctx2, desc)
if err != nil {
u.release()
Expand All @@ -480,11 +487,12 @@ func (u *Unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec
if err != nil && !errors.Is(err, images.ErrSkipDesc) {
return err
}
close(done[i])
if ch != nil {
close(ch)
}

return nil
})
layerSpan.End()
}

return eg.Wait()
Expand Down

0 comments on commit 681a083

Please sign in to comment.