From 6d2e9314b19e8db3ed278e8ee58b1bd889985f1d Mon Sep 17 00:00:00 2001 From: Brad Davidson Date: Fri, 22 Mar 2024 22:06:07 +0000 Subject: [PATCH] Fix error when image has already been pulled CRI and containerd APIs disagree about the registry names - CRI supports index.docker.io as an alias for docker.io, while containerd does not. Use the actual stored RepoTag to determine what image to ask containerd for. Signed-off-by: Brad Davidson (cherry picked from commit f099bfa508ede0532ede16ec6d4521cb8b144de6) --- pkg/agent/containerd/containerd.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/agent/containerd/containerd.go b/pkg/agent/containerd/containerd.go index bf55cbb91a..4af199e52c 100644 --- a/pkg/agent/containerd/containerd.go +++ b/pkg/agent/containerd/containerd.go @@ -353,19 +353,23 @@ func prePullImages(ctx context.Context, client *containerd.Client, imageClient r scanner := bufio.NewScanner(imageList) for scanner.Scan() { name := strings.TrimSpace(scanner.Text()) - if _, err := imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{ + + if status, err := imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{ Image: &runtimeapi.ImageSpec{ Image: name, }, - }); err == nil { + }); err == nil && status.Image != nil && len(status.Image.RepoTags) > 0 { logrus.Infof("Image %s has already been pulled", name) - if image, err := imageService.Get(ctx, name); err != nil { - errs = append(errs, err) - } else { - images = append(images, image) + for _, tag := range status.Image.RepoTags { + if image, err := imageService.Get(ctx, tag); err != nil { + errs = append(errs, err) + } else { + images = append(images, image) + } } continue } + logrus.Infof("Pulling image %s", name) if _, err := imageClient.PullImage(ctx, &runtimeapi.PullImageRequest{ Image: &runtimeapi.ImageSpec{