From de0019bf3553ee2e7ec04a9475fdaa9e31b63171 Mon Sep 17 00:00:00 2001 From: coryb Date: Wed, 14 Jul 2021 09:08:28 -0700 Subject: [PATCH] fix dropped pull progress output due to canceled context fixes #2248 Signed-off-by: coryb --- source/containerimage/pull.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/source/containerimage/pull.go b/source/containerimage/pull.go index 4236650ad5fd..b6365f9460d5 100644 --- a/source/containerimage/pull.go +++ b/source/containerimage/pull.go @@ -173,6 +173,10 @@ func mainManifestKey(ctx context.Context, desc specs.Descriptor, platform specs. func (p *puller) CacheKey(ctx context.Context, g session.Group, index int) (cacheKey string, cacheOpts solver.CacheOpts, cacheDone bool, err error) { p.Puller.Resolver = resolver.DefaultPool.GetResolver(p.RegistryHosts, p.Ref, "pull", p.SessionManager, g).WithImageStore(p.ImageStore, p.id.ResolveMode) + // progressFactory needs the outer context, the context in `p.g.Do` will + // be canceled before the progress output is complete + progressFactory := progress.FromContext(ctx) + _, err = p.g.Do(ctx, "", func(ctx context.Context) (_ interface{}, err error) { if p.cacheKeyErr != nil || p.cacheKeyDone == true { return nil, p.cacheKeyErr @@ -201,7 +205,7 @@ func (p *puller) CacheKey(ctx context.Context, g session.Group, index int) (cach if len(p.manifest.Descriptors) > 0 { progressController := &controller.Controller{ - WriterFactory: progress.FromContext(ctx), + WriterFactory: progressFactory, } if p.vtx != nil { progressController.Digest = p.vtx.Digest()