fix loading an image from tar failing on existing delete
parent
521648c7c8
commit
6d4eec056b
|
@ -269,11 +269,8 @@ func transferAndLoadImage(cr command.Runner, k8s config.KubernetesConfig, src st
|
||||||
return errors.Wrap(err, "runtime")
|
return errors.Wrap(err, "runtime")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := r.RemoveImage(imgName); err != nil {
|
if err := removeExistingImage(r, src, imgName); err != nil {
|
||||||
errStr := strings.ToLower(err.Error())
|
return err
|
||||||
if !strings.Contains(errStr, "no such image") {
|
|
||||||
return errors.Wrap(err, "removing image")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
klog.Infof("Loading image from: %s", src)
|
klog.Infof("Loading image from: %s", src)
|
||||||
|
@ -309,6 +306,26 @@ func transferAndLoadImage(cr command.Runner, k8s config.KubernetesConfig, src st
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeExistingImage(r cruntime.Manager, src string, imgName string) error {
|
||||||
|
// if loading an image from tar, skip deleting as we don't have the actual image name
|
||||||
|
// ie. imgName = "C:\this_is_a_dir\image.tar.gz"
|
||||||
|
if src == imgName {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
err := r.RemoveImage(imgName)
|
||||||
|
if err == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
errStr := strings.ToLower(err.Error())
|
||||||
|
if !strings.Contains(errStr, "no such image") {
|
||||||
|
return errors.Wrap(err, "removing image")
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// pullImages pulls images to the container run time
|
// pullImages pulls images to the container run time
|
||||||
func pullImages(cruntime cruntime.Manager, images []string) error {
|
func pullImages(cruntime cruntime.Manager, images []string) error {
|
||||||
klog.Infof("PullImages start: %s", images)
|
klog.Infof("PullImages start: %s", images)
|
||||||
|
|
Loading…
Reference in New Issue