-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
This PR allows users to remove external containers directly #7891
Conversation
[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 |
pkg/domain/infra/abi/containers.go
Outdated
// Attempt to remove named containers directly from storage, if container is defined in libpod | ||
// this will fail, if options.Storage is not specified, code will fall through to removing | ||
// the container from libpod.` | ||
i := 0 |
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.
Please just make a new array - the memory savings/speed optimization here is going to be minor and these is a lot less readable than appending failed names to a fresh array.
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.
Fixed
pkg/domain/infra/abi/containers.go
Outdated
report.Err = err | ||
if options.Storage { | ||
reports = append(reports, &report) | ||
return reports, nil |
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.
This doesn't seem correct - the old --storage
behavior was to try all images, not fail when only one failed.
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.
No it was not, the code, would attempt to remove the nameOrIDs from containerStorage. But now it will do it if the container exists in storage and not in libpod. Making the storage flag useless. I am going to just hide it and remove it from docs.
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 I am saying is that the new code will return an error after any single image fails. The old code tried all images, even if one failed.
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.
I think we just remove the storage option altogether, if the image does not exists in libpod, it will report and error now, and it will be removed if it is just in container/storage.
00cb33d
to
da1e691
Compare
I'm a bit confused by the change. I thought we wanted to not allow this so that someone would have to think before removing a storage container.... I could see changing the error message to be more explanatory in that regard, but are we all comfortable with just removing a container that wasn't created by Podman? I'm going to think some people will no like that and I'm not sure which is the lesser evil if you will. |
@TomSweeneyRedHat The only way to remove a container would be to fully specify the name. This is not going to happen via --latest or --all. You basically would have to find the name of the container via podman ps --storage or an error message perhaps in podman stop. Then you need to do podman stop UUID. The chance of someone doing this by mistake is nil. Currently the UI does
Which is a lie, and changing this to something that said to me to add --storage just feels like a bad UI. |
Does that example actually work? I seem to remember 'rm --storage'
requiring a full ID to work.
…On Sat, Oct 3, 2020, 05:54 Daniel J Walsh ***@***.***> wrote:
@TomSweeneyRedHat <https://github.com/TomSweeneyRedHat> The only way to
remove a container would be to fully specify the name. This is not going to
happen via --latest or --all. You basically would have to find the name of
the container via podman ps --storage or an error message perhaps in podman
stop.
Then you need to do podman stop UUID. The chance of someone doing this by
mistake is nil.
Currently the UI does
# buildah from alpine
alpine-working-container
# podman rm alpine-working-container
Error: no container with name or ID alpine-working-container found: no such container
Which is a lie, and changing this to something that said to me to add
--storage just feels like a bad UI.
It is not like the user just typed these random characters and
accidentally hit a container name.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#7891 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AB3AOCBUZFH4OFKNJ3IDMUTSI3YF5ANCNFSM4SBT5MWQ>
.
|
Yes this example works It is the primary reason for this PR. This test added in this PR makes the change. |
f45ca63
to
039289b
Compare
if len(tmpNames) < len(names) { | ||
names = tmpNames | ||
} | ||
|
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.
Should we have a check here to return immediately if len(names) == 0 (everything was a storage container)?
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.
No because we have not processed --all or --latest yet.
But there was a bug below.
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.
LGTM
LGTM with mheon's suggestion addressed. |
Currenly if a user specifies the name or ID of an external storage container, we report an error to them. buildah from scratch working-container-2 podman rm working-container-2 Error: no container with name or ID working-container-2 found: no such container Since the user specified the correct name and the container is in storage we force them to specify --storage to remove it. This is a bad experience for the user. This change will just remove the container from storage. If the container is known by libpod, it will remove the container from libpod as well. The podman rm --storage option has been deprecated, and removed from docs. Also cleaned documented options that are not available to podman-remote. Signed-off-by: Daniel J Walsh <[email protected]>
/lgtm |
/hold cancel |
Currenly if a user specifies the name or ID of an external storage
container, we report an error to them.
buildah from scratch
working-container-2
podman rm working-container-2
Error: no container with name or ID working-container-2 found: no such container
Since the user specified the correct name and the container is in storage we
force them to specify --storage to remove it. This is a bad experience for the
user.
This change will just remove the container from storage. If the container
is known by libpod, it will remove the container from libpod as well.
If the user species the --storage option, and the container is known to libpod
the command will fail.
Also cleaned documented options that are not available to podman-remote.
Signed-off-by: Daniel J Walsh [email protected]