mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
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)
This commit is contained in:
parent
5c113cf435
commit
5b3a44fd56
@ -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)
|
klog.V(4).Infof("The reference %s does not directly refer to the given image's ID (%q)", image, inspected.ID)
|
||||||
return false
|
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
|
|
||||||
}
|
|
||||||
|
@ -399,7 +399,7 @@ func (d *kubeDockerClient) RemoveImage(image string, opts dockertypes.ImageRemov
|
|||||||
if ctxErr := contextError(ctx); ctxErr != nil {
|
if ctxErr := contextError(ctx); ctxErr != nil {
|
||||||
return nil, ctxErr
|
return nil, ctxErr
|
||||||
}
|
}
|
||||||
if isImageNotFoundError(err) {
|
if dockerapi.IsErrNotFound(err) {
|
||||||
return nil, ImageNotFoundError{ID: image}
|
return nil, ImageNotFoundError{ID: image}
|
||||||
}
|
}
|
||||||
return resp, err
|
return resp, err
|
||||||
|
Loading…
Reference in New Issue
Block a user