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

Don't remove pinned images on image prune #1360

Conversation

sondavidb
Copy link
Contributor

@sondavidb sondavidb commented Feb 22, 2024

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?

crictl rmi will not remove pinned images on --prune

@k8s-ci-robot k8s-ci-robot added the kind/feature Categorizes issue or PR as related to a new feature. label Feb 22, 2024
Copy link

linux-foundation-easycla bot commented Feb 22, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

  • ✅ login: sondavidb / name: David Son (af4707c)

@k8s-ci-robot k8s-ci-robot added the cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. label Feb 22, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @sondavidb!

It looks like this is your first PR to kubernetes-sigs/cri-tools 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cri-tools has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Feb 22, 2024
Comment on lines 393 to 397
// 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
}
Copy link
Contributor

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?

Suggested change
// 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.

Copy link
Contributor Author

@sondavidb sondavidb Feb 23, 2024

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

@sondavidb sondavidb force-pushed the dont-remove-pinned-images-on-prune branch from b25828e to 0413082 Compare February 23, 2024 18:07
This fix also stops crictl from erreneously removing running pause
containers.

Signed-off-by: David Son <davbson@amazon.com>
@sondavidb sondavidb force-pushed the dont-remove-pinned-images-on-prune branch from 0413082 to af4707c Compare February 23, 2024 23:38
@kwilczynski
Copy link
Contributor

@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.

@kwilczynski
Copy link
Contributor

/approved
/lgtm

@k8s-ci-robot
Copy link
Contributor

@kwilczynski: changing LGTM is restricted to collaborators

In response to this:

/approved
/lgtm

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.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 26, 2024
@k8s-ci-robot
Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 26, 2024
@k8s-ci-robot k8s-ci-robot merged commit f638383 into kubernetes-sigs:master Feb 26, 2024
23 checks passed
@kwilczynski
Copy link
Contributor

/release-note-edit crictl rmi will not remove pinned images on --prune

@sondavidb sondavidb deleted the dont-remove-pinned-images-on-prune branch February 27, 2024 22:49
@kwilczynski
Copy link
Contributor

/release-note-edit crictl rmi will not remove pinned images on --prune

@saschagrunert, this is probably something only you could do. Unless it's too late already.

@saschagrunert
Copy link
Member

/release-note-edit crictl rmi will not remove pinned images on --prune

@saschagrunert, this is probably something only you could do. Unless it's too late already.

Done 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Don't remove pinned images when pruning
4 participants