Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pkg/backend/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,26 +88,26 @@ func (b *backend) Pull(ctx context.Context, target string, cfg *config.Pull) err

// copy the layers.
dst := b.store
g, ctx := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.SetLimit(cfg.Concurrency)

var fn func(desc ocispec.Descriptor) error
if cfg.ExtractFromRemote {
fn = func(desc ocispec.Descriptor) error {
return pullAndExtractFromRemote(ctx, pb, internalpb.NormalizePrompt("Pulling blob"), src, cfg.ExtractDir, desc)
return pullAndExtractFromRemote(gctx, pb, internalpb.NormalizePrompt("Pulling blob"), src, cfg.ExtractDir, desc)
}
} else {
fn = func(desc ocispec.Descriptor) error {
return pullIfNotExist(ctx, pb, internalpb.NormalizePrompt("Pulling blob"), src, dst, desc, repo, tag)
return pullIfNotExist(gctx, pb, internalpb.NormalizePrompt("Pulling blob"), src, dst, desc, repo, tag)
}
}

logrus.Infof("pull: processing layers for target %s [count: %d]", target, len(manifest.Layers))
for _, layer := range manifest.Layers {
g.Go(func() error {
select {
case <-ctx.Done():
return ctx.Err()
case <-gctx.Done():
return gctx.Err()
Comment thread
chlins marked this conversation as resolved.
default:
}

Expand All @@ -124,7 +124,7 @@ func (b *backend) Pull(ctx context.Context, target string, cfg *config.Pull) err
}

return err
}, append(defaultRetryOpts, retry.Context(ctx))...)
}, append(defaultRetryOpts, retry.Context(gctx))...)
})
}

Expand Down
10 changes: 5 additions & 5 deletions pkg/backend/push.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,26 +77,26 @@ func (b *backend) Push(ctx context.Context, target string, cfg *config.Push) err
// note: the order is important, manifest should be pushed at last.

// copy the layers.
g, ctx := errgroup.WithContext(ctx)
g, gctx := errgroup.WithContext(ctx)
g.SetLimit(cfg.Concurrency)

logrus.Infof("push: processing layers for target %s [count: %d]", target, len(manifest.Layers))
for _, layer := range manifest.Layers {
g.Go(func() error {
Comment thread
chlins marked this conversation as resolved.
select {
case <-ctx.Done():
return ctx.Err()
case <-gctx.Done():
return gctx.Err()
Comment thread
chlins marked this conversation as resolved.
default:
}

return retry.Do(func() error {
logrus.Debugf("push: processing layer %s", layer.Digest)
if err := pushIfNotExist(ctx, pb, internalpb.NormalizePrompt("Copying blob"), src, dst, layer, repo, tag); err != nil {
if err := pushIfNotExist(gctx, pb, internalpb.NormalizePrompt("Copying blob"), src, dst, layer, repo, tag); err != nil {
return err
}
logrus.Debugf("push: successfully processed layer %s", layer.Digest)
return nil
}, append(defaultRetryOpts, retry.Context(ctx))...)
}, append(defaultRetryOpts, retry.Context(gctx))...)
})
}

Expand Down