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

rm: set exit code to 1 if a specified container is not found #2540

Merged

Conversation

giuseppe
Copy link
Member

@giuseppe giuseppe commented Mar 5, 2019

Closes: #2539

Signed-off-by: Giuseppe Scrivano gscrivan@redhat.com

Closes: containers#2539

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: giuseppe

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 Mar 5, 2019
@rhatdan
Copy link
Member

rhatdan commented Mar 5, 2019

We already have this?
Do you see a way that this is broken?

podman rm foobar
Error: unable to find container foobar: no container with name or ID foobar found: no such container
[dwalsh@localhost container-selinux]$ echo $?
1

@rhatdan
Copy link
Member

rhatdan commented Mar 5, 2019

e41279b

@rhatdan
Copy link
Member

rhatdan commented Mar 5, 2019

Ok I looked at the issue and it looks like I missed this use case.
LGTM

@rhatdan
Copy link
Member

rhatdan commented Mar 5, 2019

@@ -80,6 +80,9 @@ func rmCmd(c *cliconfig.RmValues) error {
return err
}
if err != nil {
if errors.Cause(err) == libpod.ErrNoSuchCtr {
exitCode = 1
}
fmt.Println(err.Error())
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 just wondering if we should error out at this point and not try the deletions? If it's OK to continue on and delete what we can, then LGTM.

Copy link
Member Author

Choose a reason for hiding this comment

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

we document that we return 1 if a container is not found

Copy link
Member

Choose a reason for hiding this comment

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

the desired behaviour is to keep going and output at the end.

@baude
Copy link
Member

baude commented Mar 5, 2019

/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Mar 5, 2019
@openshift-merge-robot openshift-merge-robot merged commit b62540c into containers:master Mar 5, 2019
@@ -80,6 +80,9 @@ func rmCmd(c *cliconfig.RmValues) error {
return err
}
if err != nil {
if errors.Cause(err) == libpod.ErrNoSuchCtr {
exitCode = 1
Copy link
Member

Choose a reason for hiding this comment

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

We need to reset exitCode if further errors are encountered. eg.:

$ podman rm bogus running-container

It looks like commit 35432ec masked this problem for rootless usage, but it still holds for the rootful case. I submitted #2632 for this.

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

8 participants