-
Notifications
You must be signed in to change notification settings - Fork 40k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CRI: Image pullable support in dockershim #34380
Conversation
Jenkins Kubemark GCE e2e failed for commit bb7e3e9. Full PR test history. The magic incantation to run this job again is |
Jenkins GCI GCE e2e failed for commit bb7e3e9. Full PR test history. The magic incantation to run this job again is |
@k8s-bot cri test this. |
@Random-Liu nit: #33014 has been reverted. |
Image: &image.Image, | ||
}, | ||
}) | ||
status, err := m.imageService.ImageStatus(&runtimeApi.ImageSpec{Image: &image.Image}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we return an error if the image is not found?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could, we just need to define different types of error then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Random-Liu I suggest we define and return an error then.
BTW, it seems the dockershim will return nil, error
when the image doesn't exist.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Random-Liu Alternatively, can't dockershim support filtering the images through digest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
BTW, it seems the dockershim will return nil, error when the image doesn't exist.
@yifan-gu dockershim returns nil, nil
https://github.com/kubernetes/kubernetes/pull/34380/files#diff-99802aef301353226cc4233749846c68R58
@Random-Liu Alternatively, can't dockershim support filtering the images through digest?
@yifan-gu Docker itself doesn't support filter image by digest when listing images.
We can implement it ourselves, but I feel like it is simpler and makes more sense to use ImageStatus
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Random-Liu OK, but I still suggest return not found
as an error, which is somehow a convention, e.g. os.Stat()
.
bb7e3e9
to
3941cf3
Compare
@k8s-bot cri test this. |
@yujuhong The test passed! :) Do you want to take a look. |
LGTM |
@@ -46,7 +46,8 @@ service RuntimeService { | |||
service ImageService { | |||
// ListImages lists existing images. | |||
rpc ListImages(ListImagesRequest) returns (ListImagesResponse) {} | |||
// ImageStatus returns the status of the image. | |||
// ImageStatus returns the status of the image. If the image doesn't |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/doesn't/is not
@@ -51,16 +50,16 @@ func (ds *dockerService) ListImages(filter *runtimeApi.ImageFilter) ([]*runtimeA | |||
return result, nil | |||
} | |||
|
|||
// ImageStatus returns the status of the image. | |||
// ImageStatus returns the status of the image, returns nil if the image doesn't present. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/doesn't/is not
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
_, err := ds.client.RemoveImage(image.GetImage(), dockertypes.ImageRemoveOptions{PruneChildren: true}) | ||
// If the image has multiple tags, we need to remove all the tags | ||
// TODO: We assume image.Image is image ID here, which is true in the current implementation | ||
// of kubelet, but we should still clarify this kind of thing in CRI. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove kind of thing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK
@@ -79,6 +78,19 @@ func (ds *dockerService) PullImage(image *runtimeApi.ImageSpec, auth *runtimeApi | |||
|
|||
// RemoveImage removes the image. | |||
func (ds *dockerService) RemoveImage(image *runtimeApi.ImageSpec) error { | |||
_, err := ds.client.RemoveImage(image.GetImage(), dockertypes.ImageRemoveOptions{PruneChildren: true}) | |||
// If the image has multiple tags, we need to remove all the tags | |||
// TODO: We assume image.Image is image ID here, which is true in the current implementation |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the assumption necessary?
If we want to make the assumption, maybe we should switch to using ImageRef
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the assumption necessary?
No, the comment is only for this PR. I'll send another PR to change the API a bit.
If we want to make the assumption, maybe we should switch to using ImageRef.
Yeah, I think so.
@Random-Liu we talked about using |
I tried to change the code and found that we also use If so, it seems that only |
* Fix inspect image bug. * Fix remove image bug.
3941cf3
to
afa3414
Compare
@yujuhong Addressed comments. |
LGTM. Let's get this in first to stop the test failures. We can talk about changing the API later. |
@k8s-bot test this [submit-queue is verifying that this PR is safe to merge] |
Jenkins GCI GKE smoke e2e failed for commit afa3414. Full PR test history. The magic incantation to run this job again is |
Automatic merge from submit-queue |
For #33189.
The new test
ImageID should be set to the manifest digest (from RepoDigests) when available
introduced in #33014 is failing, because:docker-pullable://
conversion is not supported in dockershim;kuberuntime
anddockershim
is usingListImages with image name filter
to check whether image presents. However,ListImages
doesn't support filter withdigest
.This PR:
kuberuntime.IsImagePresent
to useruntime.ImageStatus
anddockershim.InspectImage
instead. _Notice an API change:ImageStatus
should return(nil, nil)
for non-existing image._docker-pullable://
support.RemoveImage
in dockershim Removing images with multiple tags #29316.I've tried myself, the test can pass now.
@yujuhong @feiskyer @yifan-gu
/cc @kubernetes/sig-node
This change is