Merge pull request #17671 from prezha/fix-containerd-ImageExists
fix containerd ImageExists to look for image name and image id shapull/17676/head
commit
bfffdb9fbc
|
@ -248,12 +248,12 @@ func (r *Containerd) Disable() error {
|
||||||
|
|
||||||
// ImageExists checks if image exists based on image name and optionally image sha
|
// ImageExists checks if image exists based on image name and optionally image sha
|
||||||
func (r *Containerd) ImageExists(name string, sha string) bool {
|
func (r *Containerd) ImageExists(name string, sha string) bool {
|
||||||
c := exec.Command("/bin/bash", "-c", fmt.Sprintf("sudo ctr -n=k8s.io images check | grep %s", name))
|
klog.Infof("Checking existence of image with name %q and sha %q", name, sha)
|
||||||
rr, err := r.Runner.RunCmd(c)
|
c := exec.Command("sudo", "ctr", "-n=k8s.io", "images", "check")
|
||||||
if err != nil {
|
// note: image name and image id's sha can be on different lines in ctr output
|
||||||
return false
|
if rr, err := r.Runner.RunCmd(c); err != nil ||
|
||||||
}
|
!strings.Contains(rr.Output(), name) ||
|
||||||
if sha != "" && !strings.Contains(rr.Output(), sha) {
|
(sha != "" && !strings.Contains(rr.Output(), sha)) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in New Issue