From 32e2c53467fac52891940da48628d5fbef09ed44 Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Sat, 16 Sep 2023 13:07:13 +0200 Subject: [PATCH] c8d: Fix pull progress update We were sending the "Pulling from ..." message too early, if the pull progress wasn't able to resolve the image we wouldn't sent the error back. Sending that first message would have flushed the output stream and image_routes.go would return a nil error. Signed-off-by: Djordje Lukic --- daemon/containerd/image_pull.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/daemon/containerd/image_pull.go b/daemon/containerd/image_pull.go index b40eef65d8..3e556ef068 100644 --- a/daemon/containerd/image_pull.go +++ b/daemon/containerd/image_pull.go @@ -73,8 +73,14 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, finishProgress := jobs.showProgress(ctx, out, pp) defer finishProgress() + var sentPullingFrom bool ah := images.HandlerFunc(func(ctx context.Context, desc ocispec.Descriptor) ([]ocispec.Descriptor, error) { if images.IsManifestType(desc.MediaType) { + if !sentPullingFrom { + progress.Message(out, tagOrDigest, "Pulling from "+reference.Path(ref)) + sentPullingFrom = true + } + available, _, _, missing, err := images.Check(ctx, i.client.ContentStore(), desc, p) if err != nil { return nil, err @@ -98,8 +104,6 @@ func (i *ImageService) PullImage(ctx context.Context, image, tagOrDigest string, infoHandler := snapshotters.AppendInfoHandlerWrapper(ref.String()) opts = append(opts, containerd.WithImageHandlerWrapper(infoHandler)) - progress.Message(out, tagOrDigest, "Pulling from "+reference.Path(ref)) - img, err := i.client.Pull(ctx, ref.String(), opts...) if err != nil { return err