diff --git a/daemon/images/image_pull.go b/daemon/images/image_pull.go index a0d46db55303f..eff7ef90f8793 100644 --- a/daemon/images/image_pull.go +++ b/daemon/images/image_pull.go @@ -76,7 +76,6 @@ func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference go func() { progressutils.WriteDistributionProgress(cancelFunc, outStream, progressChan) - close(writesDone) }() ctx = namespaces.WithNamespace(ctx, i.contentNamespace) @@ -86,7 +85,6 @@ func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference if err != nil { return err } - defer done(ctx) cs := &contentStoreForPull{ ContentStore: i.content, @@ -115,16 +113,13 @@ func (i *ImageService) pullImageWithReference(ctx context.Context, ref reference err = distribution.Pull(ctx, ref, imagePullConfig, cs) close(progressChan) + done(ctx) <-writesDone return err } func tempLease(ctx context.Context, mgr leases.Manager) (context.Context, func(context.Context) error, error) { nop := func(context.Context) error { return nil } - _, ok := leases.FromContext(ctx) - if ok { - return ctx, nop, nil - } // Use an expiration that ensures the lease is cleaned up at some point if there is a crash, SIGKILL, etc. opts := []leases.Opt{