Skip to content

Commit

Permalink
fix dropped pull progress output due to canceled context
Browse files Browse the repository at this point in the history
fixes moby#2248

Signed-off-by: coryb <cbennett@netflix.com>
  • Loading branch information
coryb committed Jul 14, 2021
1 parent 699121c commit de0019b
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion source/containerimage/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit de0019b

Please sign in to comment.