-
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
When removing objects specifying --force,podman should exit with 0 #14959
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 |
Replaces: #14782 |
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.
We should never print an error when exiting with 0.
At least for the commands that have --ignore, --force should just imply ignore to fix this.
cmd/podman/pods/rm.go
Outdated
@@ -104,13 +109,17 @@ func removePods(namesOrIDs []string, rmOptions entities.PodRmOptions, printIDs b | |||
fmt.Println(r.Id) | |||
} | |||
} else { | |||
fmt.Println("DAN", rmOptions.Force, r.Err, define.ErrNoSuchPod) |
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.
debug
cmd/podman/volumes/rm.go
Outdated
setExitCode(err) | ||
return err | ||
} | ||
for _, r := range responses { | ||
if r.Err == nil { | ||
fmt.Println(r.Id) | ||
} else { | ||
if rmOptions.Force && strings.Contains(r.Err.Error(), define.ErrNoSuchVolume.Error()) { | ||
fmt.Fprintf(os.Stderr, "Error: %v\n", r.Err) | ||
return 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.
continue?
In order to match Docker, we need to print the error and exit with 0. |
9a17726
to
95585e5
Compare
fb9e022
to
43af553
Compare
I find that behaviour very confusion and I personally would be against matching docker here. Printing an error but still exiting with 0 is just stupid IMHO. |
@Luap99 - Could you elaborate on why you think exiting with 0 and printing an error message would not be a good idea? I don't see why that would be an issue. Error messages will help us better understand what is going on if an error occurs. Additionally, I think matching Docker makes sense. It would be confusing to have the behavior not match for these tools. |
Because that goes against common sense. If a application tells me (a user) that there is an error but still exits 0 it says two different things at the same time. Consider the following example from GNU
|
Ok, I agree with @Luap99 Will removing printing the error. |
d322c75
to
f7bb9cc
Compare
/hold |
faa5480
to
4b423b6
Compare
@vrothberg @Luap99 @edsantiago PTAL |
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 know @Luap99 asked not to print the error but if we really aim at Docker compat I fear we do not have choice.
run_podman 1 network rm bogus | ||
is "$output" "Error: unable to find network with name or ID bogus: network not found" "Should print error" | ||
run_podman network rm --force bogus | ||
is "$output" "" "Should print no output" |
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.
That is not how Docker behaves:
~ $ sudo docker rm -f bogus
Error: No such container: bogus
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.
If we don't care about this compat, users could just use --ignore
and we don't need this PR.
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.
But I am not married to printing the error. If others feel strongly about it, feel free to merge. In the general case we should remain compatible where possible - sometimes bug compatible.
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.
If we don't care about this compat, users could just use
--ignore
and we don't need this PR.
No right no we exit with code > 0. The goal is to exit with 0, so basically --force should imply --ignore IMO.
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.
IIRC we decided --force not imply --ignore when adding --ignore as we were afraid of breaking backwards compat with existing Podman users. But I also think --force should imply it ... just as so many other tools do.
We break compat occasionally, when there's good reason to. I'm feeling that this is one of those cases. Printing error messages when a command exited 0 is nonsensical. Is there a specific usecase we're aware of that actually printing the error messages serves? If we don't have a case where it actively breaks someone, I would be in favor of not printing the error. |
One of the test failures (rmi -a) is because old-podman would say "Error: 2 errors occurred", new-podman does not: $ old-podman rmi -a
Error: 2 errors occurred:
* Image used by sha1: image is in use by a container
* Image used by sha2: image is in use by a container
$ new-podman rmi -a
Error: image used by sha1: image is in use by a container
Error: image used by sha2: image is in use by a container |
This Patch will cause podman COMMAND rm --force bogus not fail This is how Docker works, so Podman should follow this to allow existing scripts to convert from Docker to Podman. Fixes: containers#14612 Oprignal version of this patch came from wufan [email protected] Signed-off-by: Daniel J Walsh <[email protected]>
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. I, too, agree that the behavior this PR introduces (silence, exit 0) is the correct one even if another nameless client-daemon tool does it differently. |
This Patch will cause podman COMMAND rm --force bogus exit with 0.
This is how Docker works, so Podman should follow this to allow existing
scripts to convert from Docker to Podman.
Fixes: #14612
Signed-off-by: wufan [email protected]
Signed-off-by: Daniel J Walsh [email protected]
Does this PR introduce a user-facing change?