MCPcopy
hub / github.com/containerd/containerd / fetch

Method fetch

core/unpack/unpacker.go:657–701  ·  view source on GitHub ↗
(ctx context.Context, h images.Handler, layers []ocispec.Descriptor, done []chan struct{})

Source from the content-addressed store, hash-verified

655}
656
657func (u *Unpacker) fetch(ctx context.Context, h images.Handler, layers []ocispec.Descriptor, done []chan struct{}) error {
658 eg, ctx2 := errgroup.WithContext(ctx)
659 for i, desc := range layers {
660 ctx2, layerSpan := tracing.StartSpan(ctx2, tracing.Name(unpackSpanPrefix, "fetchLayer"))
661 layerSpan.SetAttributes(
662 tracing.Attribute("layer.media.type", desc.MediaType),
663 tracing.Attribute("layer.media.size", desc.Size),
664 tracing.Attribute("layer.media.digest", desc.Digest.String()),
665 )
666 var ch chan struct{}
667 if done != nil {
668 ch = done[i]
669 }
670
671 if err := u.acquire(ctx, u.limiter); err != nil {
672 return err
673 }
674
675 eg.Go(func() error {
676 defer layerSpan.End()
677
678 unlock, err := u.lockBlobDescriptor(ctx2, desc)
679 if err != nil {
680 u.release(u.limiter)
681 return err
682 }
683
684 _, err = h.Handle(ctx2, desc)
685
686 unlock()
687 u.release(u.limiter)
688
689 if err != nil && !errors.Is(err, images.ErrSkipDesc) {
690 return err
691 }
692 if ch != nil {
693 close(ch)
694 }
695
696 return nil
697 })
698 }
699
700 return eg.Wait()
701}
702
703func (u *Unpacker) acquire(ctx context.Context, l Limiter) error {
704 if l == nil {

Callers 1

unpackMethod · 0.95

Calls 11

acquireMethod · 0.95
lockBlobDescriptorMethod · 0.95
releaseMethod · 0.95
StartSpanFunction · 0.92
NameFunction · 0.92
AttributeFunction · 0.92
SetAttributesMethod · 0.80
EndMethod · 0.80
HandleMethod · 0.65
WaitMethod · 0.65
StringMethod · 0.45

Tested by

no test coverage detected