-
Notifications
You must be signed in to change notification settings - Fork 460
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
Don't remove pinned images on image prune #1360
Don't remove pinned images on image prune #1360
Conversation
|
Welcome @sondavidb! |
cmd/crictl/image.go
Outdated
// Pinned images should not be removed on prune. | ||
if all || (prune && !img.Pinned) { | ||
logrus.Debugf("Adding image to be removed: %v", img.GetId()) | ||
ids[img.GetId()] = true | ||
} |
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.
What about something like this?
// Pinned images should not be removed on prune. | |
if all || (prune && !img.Pinned) { | |
logrus.Debugf("Adding image to be removed: %v", img.GetId()) | |
ids[img.GetId()] = true | |
} | |
// Pinned images should not be removed on prune. | |
if prune && img.Pinned { | |
logrus.Debugf("Excluding pinned container image: %v", img.GetId()) | |
continue | |
} | |
logrus.Debugf("Adding container image to be removed: %v", img.GetId()) | |
ids[img.GetId()] = true |
I updated the wording to match other log messages.
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.
Makes sense, I think it would be helpful in case users are confused why certain images are not being removed. Updated PR to reflect these changes.
EDIT: Properly edited the PR to reflect these changes, sorry about that
b25828e
to
0413082
Compare
This fix also stops crictl from erreneously removing running pause containers. Signed-off-by: David Son <[email protected]>
0413082
to
af4707c
Compare
@sondavidb, looks good! For testing, have a look at the testes that were recently added as part of some other Pull Request. Perhaps it will give you an idea how to do it. This will cover unit tests, for end-to-end testes, it would be a bit more involved to do, albeit not impossible. However, manual testing is also fine. |
/approved |
@kwilczynski: changing LGTM is restricted to collaborators In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: saschagrunert, sondavidb The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/release-note-edit |
@saschagrunert, this is probably something only you could do. Unless it's too late already. |
Done 👍 |
Is there any plan to cherry pick this fix?/ |
@wangyuan0916, cherry-pick to which version? You should be able to pick up latest version of the CLI without any issues, it should work with older versions of CRI-O and such, given that we implement the specification and such. What issues are you having? |
Hi @kwilczynski , thank you for your reply. We are in kubernetes 1.28.x. I check the cri-tools README about the Compatibility matrix and find that the kubernetes and cri-tool minor versions should be the same. So can I use the latest cri-tool with kubernetes 1.28.x? Or is it better to get this fix backported? |
[...]
@wangyuan0916, try. 😄 If things work, then you get the latest version with all the bug fixes and new features. If there are issues, then we can think of a backport. |
What type of PR is this?
/kind feature
What this PR does / why we need it:
On
cricrl rmi --prune
, crictl ignores the pinned images label when removing images. Not only is this unexpected behavior, it also removes the pause container, because the container runtime endpoint doesn't return the pause container in its list of running containers.This change honors the pinned label on
cricrl rmi --prune
, which also stops the pause container from being removed, as it is pinned in every workflow.Which issue(s) this PR fixes:
Fixes #1356
Special notes for your reviewer:
I'd like to add testing for this, but I haven't been able to figure out how to make it work. I just ran a simple workflow of pulling an image, pinning it, and then running
crictl rmi --prune
.Does this PR introduce a user-facing change?