diff --git a/pkg/backend/pull.go b/pkg/backend/pull.go index 1127a886..224ce6e4 100644 --- a/pkg/backend/pull.go +++ b/pkg/backend/pull.go @@ -88,17 +88,17 @@ 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) } } @@ -106,8 +106,8 @@ func (b *backend) Pull(ctx context.Context, target string, cfg *config.Pull) err for _, layer := range manifest.Layers { g.Go(func() error { select { - case <-ctx.Done(): - return ctx.Err() + case <-gctx.Done(): + return gctx.Err() default: } @@ -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))...) }) } diff --git a/pkg/backend/push.go b/pkg/backend/push.go index 18171854..87a7a261 100644 --- a/pkg/backend/push.go +++ b/pkg/backend/push.go @@ -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 { select { - case <-ctx.Done(): - return ctx.Err() + case <-gctx.Done(): + return gctx.Err() 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))...) }) }