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

Remove container from storage on --force #2281

Merged
merged 1 commit into from
Feb 11, 2019

Conversation

rhatdan
Copy link
Member

@rhatdan rhatdan commented Feb 6, 2019

Currently we can get into a state where a container exists in
storage but does not exist in libpod. If the user forces a
removal of this container, then we should remove it from storage
even if the container is owned by another tool.

Signed-off-by: Daniel J Walsh [email protected]

@rhatdan
Copy link
Member Author

rhatdan commented Feb 6, 2019

Will allow you to cleanup from #2240

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: rhatdan

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 Feb 6, 2019
cmd/podman/rm.go Outdated
@@ -42,6 +46,20 @@ Running containers will not be removed without the -f option.
}
)

// Attempt to remove containers
func removeContainersFromStorage(runtime *libpod.Runtime, ctrs []string) {
storageService := runtime.StorageService()
Copy link
Member

Choose a reason for hiding this comment

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

If we really want to do this, let's do it in libpod, so we don't need to expose these things

@@ -17,7 +17,9 @@ Remove all containers. Can be used in conjunction with -f as well.

**--force, f**

Force the removal of a running and paused containers
Force the removal of a running and paused containers. Forcing a container removal will also
Copy link
Member

Choose a reason for hiding this comment

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

"a running" to just "running" or perhaps "any running" or "all running"

Force the removal of a running and paused containers
Force the removal of a running and paused containers. Forcing a container removal will also
remove containers from container storage, if the container is not known to podman. The container
could have been created by a different container engine.
Copy link
Member

Choose a reason for hiding this comment

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

I'm hemming and hawing about whether or not to add something like: "different container engine and due to that this option should be used cautiously." IDK if that's beating over the head too much or 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.

Yes I was going down that path. I also was thinking that this can happen when you are using just podman in some weird situations. Where the database gets updated and for some reason storage does not get removed.

@TomSweeneyRedHat
Copy link
Member

Unhappy tests, changes LGTM in general and I concur with @mheon, would like to see the code in libpod it would probably be useful there for other API's.

@rhatdan
Copy link
Member Author

rhatdan commented Feb 6, 2019

bot, retest this please

@giuseppe
Copy link
Member

giuseppe commented Feb 7, 2019

LGTM

// if the container does not exist in database, attempt to remove it from storage
if _, err := r.LookupContainer(i); err != nil && errors.Cause(err) == image.ErrNoSuchCtr {
r.storageService.UnmountContainerImage(i, true)
if err := r.storageService.DeleteContainer(i); err != nil && errors.Cause(err) != storage.ErrContainerUnknown {
Copy link
Member

Choose a reason for hiding this comment

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

I think returning ErrContainerUnknown is probably better than dropping it - useful to know if we did nothing in these cases, I think.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think this is going to be a common case, since we might have attempted to remove 5 containers, and 4 succeeded and one failed on the normal path. Then running through this path would complain about the 4 successful ones.

I think it is better to just ignore containers that are already removed. Similar to rm -f /etc/foobar, will not care if /etc/foobar exists.

@rh-atomic-bot
Copy link
Collaborator

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

@openshift-ci-robot openshift-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2019
Currently we can get into a state where a container exists in
storage but does not exist in libpod.  If the user forces a
removal of this container, then we should remove it from storage
even if the container is owned by another tool.

Signed-off-by: Daniel J Walsh <[email protected]>
@openshift-ci-robot openshift-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Feb 9, 2019
@mheon
Copy link
Member

mheon commented Feb 11, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Feb 11, 2019
@openshift-merge-robot openshift-merge-robot merged commit b7a3685 into containers:master Feb 11, 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 27, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 27, 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants