mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #45808 from Crazykev/quick-fix
Automatic merge from submit-queue (batch tested with PRs 45171, 43947, 45788, 45822, 45808) [CRI] Continue remove image when can't find image id with ImageRef Signed-off-by: Crazykev <crazykev@zju.edu.cn> **What this PR does / why we need it**: Should try to remove imageRef as repo:tag when can't find it as imageID. /cc @feiskyer @Random-Liu PTAL also /cc @xlgao-zju @heartlock **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes # **Special notes for your reviewer**: **Release note**: ```release-note None ```
This commit is contained in:
commit
e11963194e
@ -101,8 +101,11 @@ func (ds *dockerService) RemoveImage(image *runtimeapi.ImageSpec) error {
|
||||
}
|
||||
}
|
||||
return nil
|
||||
} else if err != nil && libdocker.IsImageNotFoundError(err) {
|
||||
return nil
|
||||
}
|
||||
// dockerclient.InspectImageByID doesn't work with digest and repoTags,
|
||||
// it is safe to continue removing it since there is another check below.
|
||||
if err != nil && !libdocker.IsImageNotFoundError(err) {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = ds.client.RemoveImage(image.Image, dockertypes.ImageRemoveOptions{PruneChildren: true})
|
||||
|
@ -133,5 +133,8 @@ func matchImageIDOnly(inspected dockertypes.ImageInspect, image string) bool {
|
||||
// isImageNotFoundError returns whether the err is caused by image not found in docker
|
||||
// TODO: Use native error tester once ImageNotFoundError is supported in docker-engine client(eg. ImageRemove())
|
||||
func isImageNotFoundError(err error) bool {
|
||||
if err != nil {
|
||||
return strings.Contains(err.Error(), "No such image:")
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user