Skip to content
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

Merged
merged 1 commit into from
Oct 12, 2016

Conversation

Random-Liu
Copy link
Member

@Random-Liu Random-Liu commented Oct 8, 2016

For #33189.

The new test ImageID should be set to the manifest digest (from RepoDigests) when available introduced in #33014 is failing, because:

  1. docker-pullable:// conversion is not supported in dockershim;
  2. kuberuntime and dockershim is using ListImages with image name filter to check whether image presents. However, ListImages doesn't support filter with digest.

This PR:

  1. Change kuberuntime.IsImagePresent to use runtime.ImageStatus and dockershim.InspectImage instead. _Notice an API change: ImageStatus should return (nil, nil) for non-existing image._
  2. Add docker-pullable:// support.
  3. Fix 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 Reviewable

@Random-Liu Random-Liu added area/docker area/kubelet area/kubelet-api sig/node Categorizes an issue or PR as relevant to SIG Node. labels Oct 8, 2016
@Random-Liu Random-Liu added this to the 1.2 milestone Oct 8, 2016
@Random-Liu Random-Liu added the release-note-none Denotes a PR that doesn't merit a release note. label Oct 8, 2016
@k8s-github-robot k8s-github-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 8, 2016
@k8s-ci-robot
Copy link
Contributor

Jenkins Kubemark GCE e2e failed for commit bb7e3e9. Full PR test history.

The magic incantation to run this job again is @k8s-bot kubemark e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GCE e2e failed for commit bb7e3e9. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gce e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@Random-Liu
Copy link
Member Author

@k8s-bot cri test this.

@Random-Liu Random-Liu removed this from the 1.2 milestone Oct 8, 2016
@k8s-github-robot k8s-github-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 8, 2016
@feiskyer
Copy link
Member

feiskyer commented Oct 9, 2016

@Random-Liu nit: #33014 has been reverted.

Image: &image.Image,
},
})
status, err := m.imageService.ImageStatus(&runtimeApi.ImageSpec{Image: &image.Image})
Copy link
Contributor

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?

Copy link
Member Author

@Random-Liu Random-Liu Oct 11, 2016

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.

Copy link
Contributor

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.

Copy link
Contributor

@yifan-gu yifan-gu Oct 11, 2016

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?

Copy link
Member Author

@Random-Liu Random-Liu Oct 11, 2016

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.

Copy link
Contributor

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().

@Random-Liu
Copy link
Member Author

@feiskyer @yujuhong Rebased the PR.

@Random-Liu
Copy link
Member Author

@k8s-bot cri test this.

@k8s-github-robot k8s-github-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 11, 2016
@Random-Liu
Copy link
Member Author

@yujuhong The test passed! :) Do you want to take a look.

@feiskyer
Copy link
Member

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
Copy link
Contributor

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.
Copy link
Contributor

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

Copy link
Member Author

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.
Copy link
Contributor

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

Copy link
Member Author

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
Copy link
Contributor

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.

Copy link
Member Author

@Random-Liu Random-Liu Oct 12, 2016

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.

@yujuhong
Copy link
Contributor

@Random-Liu we talked about using ImageRef for all but the PullImage operation, would that be done in a separate POR?

@Random-Liu
Copy link
Member Author

Random-Liu commented Oct 12, 2016

@Random-Liu we talked about using ImageRef for all but the PullImage operation, would that be done in a separate POR?

I tried to change the code and found that we also use ImageSpec for ImageStatus. Before pulling an image, we use ImageStatus to check whether the image is present. At that time, we only have ImageSpec, because image is not pulled yet.

If so, it seems that only RemoveImage needs ImageRef.

* Fix inspect image bug.
* Fix remove image bug.
@Random-Liu
Copy link
Member Author

@yujuhong Addressed comments.

@yujuhong yujuhong added lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. labels Oct 12, 2016
@yujuhong
Copy link
Contributor

LGTM. Let's get this in first to stop the test failures. We can talk about changing the API later.

@k8s-github-robot
Copy link

@k8s-bot test this [submit-queue is verifying that this PR is safe to merge]

@k8s-ci-robot
Copy link
Contributor

Jenkins GCI GKE smoke e2e failed for commit afa3414. Full PR test history.

The magic incantation to run this job again is @k8s-bot gci gke e2e test this. Please help us cut down flakes by linking to an open flake issue when you hit one in your PR.

@k8s-github-robot
Copy link

Automatic merge from submit-queue

@k8s-github-robot k8s-github-robot merged commit b99a909 into kubernetes:master Oct 12, 2016
@Random-Liu Random-Liu deleted the fix-cri-image branch October 12, 2016 21:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/docker area/kubelet area/kubelet-api lgtm "Looks good to me", indicates that a PR is ready to be merged. priority/important-soon Must be staffed and worked on either currently, or very soon, ideally in time for the next release. release-note-none Denotes a PR that doesn't merit a release note. sig/node Categorizes an issue or PR as relevant to SIG Node. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants