Use docker api IsErrNotFound(). String handling is not required anymore

Why? https://github.com/kubernetes/kubernetes/pull/75843#discussion_r273785877
Moby support: https://github.com/moby/moby/pull/38689
Moby def: 053c6f097a/client/errors.go (L44-L49)
k3s-v1.15.3
Alok Kumar Singh 2019-04-11 20:52:57 +05:30
parent 5c113cf435
commit 5b3a44fd56
2 changed files with 1 additions and 10 deletions

View File

@ -161,12 +161,3 @@ func matchImageIDOnly(inspected dockertypes.ImageInspect, image string) bool {
klog.V(4).Infof("The reference %s does not directly refer to the given image's ID (%q)", image, inspected.ID)
return false
}
// 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
}

View File

@ -399,7 +399,7 @@ func (d *kubeDockerClient) RemoveImage(image string, opts dockertypes.ImageRemov
if ctxErr := contextError(ctx); ctxErr != nil {
return nil, ctxErr
}
if isImageNotFoundError(err) {
if dockerapi.IsErrNotFound(err) {
return nil, ImageNotFoundError{ID: image}
}
return resp, err