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

Add ability to evict a container #3549

Merged
merged 1 commit into from
Oct 4, 2019

Conversation

marcov
Copy link
Collaborator

@marcov marcov commented Jul 10, 2019

Add ability to evict a container when it becomes unusable. This may
happen when the host setup changes after a container creation, making it
impossible for that container to be used or removed.


This may happen when you create a container with a specific runtime in libpod.conf, and later the runtime name is changed in the the conf, with outcome:

$ sudo podman run -d --runtime foo-runtime alpine sleep 12345
add950497c58b4004aee3a6077658615882f8487f9dca4a337fad14c01fb4077

$ sudo sed -i "s/foo-runtime/bar-runtime/" /etc/containers/libpod.conf

$ sudo podman ps -a
ERRO[0000] Error retrieving container add950497c58b4004aee3a6077658615882f8487f9dca4a337fad14c01fb4077 from the database: cannot find OCI runtime "foo-runtime" for container add950497c58b4004aee3a6077658615882f8487f9dca4a337fad14c01fb4077: runtime not available in the current configuration
CONTAINER ID  IMAGE                        COMMAND               CREATED      STATUS                     PORTS                                          NAMES
50c843e037fe  localhost/cups-epson:latest  cupsd -f              2 hours ago  Exited (0) 31 minutes ago  0.0.0.0:6631->631/tcp, 0.0.0.0:3000->3000/tcp  suspicious_germain
c684f0d469f2  k8s.gcr.io/pause:3.1                               9 days ago   Exited (0) 31 minutes ago  0.0.0.0:6631->631/tcp, 0.0.0.0:3000->3000/tcp  e812f6be094a-infra

$ sudo podman rm -ff ad
add950497c58b4004aee3a6077658615882f8487f9dca4a337fad14c01fb4077

@openshift-ci-robot openshift-ci-robot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 10, 2019
@openshift-ci-robot openshift-ci-robot added size/XL needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 10, 2019
@openshift-ci-robot
Copy link
Collaborator

Hi @marcov. Thanks for your PR.

I'm waiting for a containers or openshift member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@marcov
Copy link
Collaborator Author

marcov commented Jul 11, 2019

@mheon I'd like your feedback on this, to see if it is going in the right direction.

@rh-atomic-bot
Copy link
Collaborator

☔ The latest upstream changes (presumably #3470) made this pull request unmergeable. Please resolve the merge conflicts.

// Evicts a container from the DB
// If the config specifies a pod, the container is treated as belonging to a pod,
// and will be removed from the pod as well
func (s *BoltState) evictContainer(ctrID []byte, config *ContainerConfig, depCtrs []string, tx *bolt.Tx) error {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm. I think we can reuse RemoveContainer() here - it doesn't actually need anything in the container state.

We can make a Container struct with a ContainerConfig we get out of GetContainerConfig, set state to an empty struct to avoid potential dereference segfaults, and pass it into RemoveContainer

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense, I have done some more refactoring and removed a good part of the duplicated code.

@marcov marcov changed the title [WIP] Add ability to evict a container Add ability to evict a container Jul 12, 2019
@openshift-ci-robot openshift-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jul 12, 2019
@marcov
Copy link
Collaborator Author

marcov commented Jul 12, 2019

@mheon unrelated to this PR: here c is a pointer, and shadowing does not make sense:
https://github.com/containers/libpod/blob/6f3e7f7eccdfed03d3d617a9040d5e0b844ea637/pkg/adapter/containers.go#L212-L213

@rhatdan
Copy link
Member

rhatdan commented Jul 12, 2019

/ok-to-test

@openshift-ci-robot openshift-ci-robot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 12, 2019
@marcov marcov force-pushed the evict-container branch 2 times, most recently from f811890 to 0c39d07 Compare July 15, 2019 10:55
@marcov
Copy link
Collaborator Author

marcov commented Aug 19, 2019

@vrothberg, if I do like you said, then how can I call iopodman.EvictContainer here?

https://github.com/containers/libpod/blob/128a1707f7d9e8df648a6ba353bfa16b9bef2431/pkg/adapter/containers_remote.go#L323-L339

@mheon
Copy link
Member

mheon commented Aug 19, 2019 via email

@rhatdan
Copy link
Member

rhatdan commented Sep 6, 2019

Any update on this PR?

@marcov
Copy link
Collaborator Author

marcov commented Sep 6, 2019

I am still willing to have this merged, just let me know if there's something to change.

@mheon
Copy link
Member

mheon commented Sep 6, 2019

I think we're relatively close - I'll do another review pass on Monday.

@giuseppe
Copy link
Member

@marcov could you please rebase this PR?

@marcov
Copy link
Collaborator Author

marcov commented Sep 16, 2019

Rebased

@vrothberg
Copy link
Member

Tests aren't happy yet. @marcov, once it's green we can merge it :)

@mheon, can you do another review?

@marcov
Copy link
Collaborator Author

marcov commented Sep 24, 2019

Failures looked unrelated at a first glance. I've rebased and let's see...

@vrothberg
Copy link
Member

@marcov, the error seems to be introduced with this PR. Running go test -v github.com/containers/libpod/libpod will report a breaking unit test.

@marcov
Copy link
Collaborator Author

marcov commented Sep 25, 2019

Thank you @vrothberg, a mere glance was not enough 😆

Add ability to evict a container when it becomes unusable. This may
happen when the host setup changes after a container creation, making it
impossible for that container to be used or removed.
Evicting a container is done using the `rm --force` command.

Signed-off-by: Marco Vedovati <mvedovati@suse.com>
@marcov
Copy link
Collaborator Author

marcov commented Sep 26, 2019

Ok, tests now are better. I don't think the only test failing is related to this PR (hopefully I'm not wrong again)

@rhatdan
Copy link
Member

rhatdan commented Sep 29, 2019

Ok this needs a review by @mheon and then we can merge.

@mheon
Copy link
Member

mheon commented Oct 4, 2019

I think we have some unsettled debate about how and when to call this - but that can happen separately.
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Oct 4, 2019
@haircommander
Copy link
Collaborator

(still needs /approve)

@mheon
Copy link
Member

mheon commented Oct 4, 2019

Oops
/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: marcov, mheon

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

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Oct 4, 2019
@openshift-merge-robot openshift-merge-robot merged commit c9e936a into containers:master Oct 4, 2019
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. ok-to-test
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet