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:
		| @@ -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 | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Alok Kumar Singh
					Alok Kumar Singh