mirror of https://github.com/k3s-io/k3s
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 <brad.davidson@rancher.com>
(cherry picked from commit f099bfa508
)
pull/9938/head
parent
8b67ddb359
commit
6d2e9314b1
|
@ -353,19 +353,23 @@ func prePullImages(ctx context.Context, client *containerd.Client, imageClient r
|
||||||
scanner := bufio.NewScanner(imageList)
|
scanner := bufio.NewScanner(imageList)
|
||||||
for scanner.Scan() {
|
for scanner.Scan() {
|
||||||
name := strings.TrimSpace(scanner.Text())
|
name := strings.TrimSpace(scanner.Text())
|
||||||
if _, err := imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{
|
|
||||||
|
if status, err := imageClient.ImageStatus(ctx, &runtimeapi.ImageStatusRequest{
|
||||||
Image: &runtimeapi.ImageSpec{
|
Image: &runtimeapi.ImageSpec{
|
||||||
Image: name,
|
Image: name,
|
||||||
},
|
},
|
||||||
}); err == nil {
|
}); err == nil && status.Image != nil && len(status.Image.RepoTags) > 0 {
|
||||||
logrus.Infof("Image %s has already been pulled", name)
|
logrus.Infof("Image %s has already been pulled", name)
|
||||||
if image, err := imageService.Get(ctx, name); err != nil {
|
for _, tag := range status.Image.RepoTags {
|
||||||
|
if image, err := imageService.Get(ctx, tag); err != nil {
|
||||||
errs = append(errs, err)
|
errs = append(errs, err)
|
||||||
} else {
|
} else {
|
||||||
images = append(images, image)
|
images = append(images, image)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
logrus.Infof("Pulling image %s", name)
|
logrus.Infof("Pulling image %s", name)
|
||||||
if _, err := imageClient.PullImage(ctx, &runtimeapi.PullImageRequest{
|
if _, err := imageClient.PullImage(ctx, &runtimeapi.PullImageRequest{
|
||||||
Image: &runtimeapi.ImageSpec{
|
Image: &runtimeapi.ImageSpec{
|
||||||
|
|
Loading…
Reference in New Issue