Skip to content

Commit

Permalink
Fix error when image has already been pulled
Browse files Browse the repository at this point in the history
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 <brad.davidson@rancher.com>
  • Loading branch information
brandond committed Mar 26, 2024
1 parent 65cd606 commit f099bfa
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions pkg/agent/containerd/containerd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand Down

0 comments on commit f099bfa

Please sign in to comment.