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

podman image rm -f returns an status code of 1 when it should return 0 #14612

Closed
crowleydi opened this issue Jun 16, 2022 · 10 comments · Fixed by #14959
Closed

podman image rm -f returns an status code of 1 when it should return 0 #14612

crowleydi opened this issue Jun 16, 2022 · 10 comments · Fixed by #14959
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

Comments

@crowleydi
Copy link

Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)

/kind bug

Description

If you run podman image rm -f non_existent_image and the image doesn't exist, it returns a status code of 1.
If you run docker image rm -f non_existent_image and the image doesn't exist, it returns a status code of 0.

For scripting compatibility between docker and podman, podman should return a status code of 0 for this situation. That is one of the points of specifying -f.

Steps to reproduce the issue:

  1. podman image rm -f foobar

  2. echo $?

Describe the results you received:

return code is 1
Describe the results you expected:
return code should be 0

Additional information you deem important (e.g. issue happens only occasionally):

Output of podman version:

podman version 4.1.1

affects older versions as well

podman version 3.4.2

Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)

Yes

Additional environment details (AWS, VirtualBox, physical, etc.):

RHEL 8 VM, Mac OSX

@openshift-ci openshift-ci bot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 16, 2022
@vrothberg vrothberg changed the title podman rm -f returns an status code of 1 when it should return 0 podman image rm -f returns an status code of 1 when it should return 0 Jun 16, 2022
@vrothberg
Copy link
Member

Thanks for reaching out, @crowleydi.

@containers/podman-maintainers WDYT?

@rhatdan
Copy link
Member

rhatdan commented Jun 16, 2022

I think Docker is correct, as long as when the command ends the container is gone, with --force podman should exit with 0.

@vrothberg
Copy link
Member

I think Docker is correct, as long as when the command ends the container is gone, with --force podman should exit with 0.

I concur. When doing the change, we should probably update the description of --ignore.

@rhatdan
Copy link
Member

rhatdan commented Jun 16, 2022

# docker rm --force bogus; echo $?
Error: No such container: bogus
0
$ podman rm --force bogus; echo $?
Error: no container with name or ID "bogus" found: no such container
1
$ podman (VENDOR) $ podman rm --force --ignore bogus; echo $?
0

Docker does not support the ignore flag. Although I am not crazy about the error being output.

@rhatdan
Copy link
Member

rhatdan commented Jun 16, 2022

We should not just do containers either

sh-5.1# docker rmi --force bogus; echo $?
Error: No such image: bogus
0
sh-5.1# podman rmi --force bogus; echo $?
Error: bogus: image not known
1
sh-5.1# podman volume rm --force bogus; echo $?
Error: no volume with name "bogus" found: no such volume
1
sh-5.1# docker volume rm --force bogus; echo $?
bogus
0

docker network rm does not support --force, but we should exit with 0.

sh-5.1# podman network rm --force bogus; echo $?
Error: unable to find network with name or ID bogus: network not found
1
sh-5.1# docker network rm --force bogus; echo $?
unknown flag: --force
See 'docker network rm --help'.
125
sh-5.1# docker network rm bogus; echo $?
Error: No such network: bogus
1

podman pod rm --force
Should exit with 0.

This calls for interns to fix up. Or if @crowleydi wants to open a PR. Hint Hint.

@rhatdan rhatdan added the Good First Issue This issue would be a good issue for a first time contributor to undertake. label Jun 16, 2022
@maknop
Copy link

maknop commented Jun 16, 2022

Could I take a shot at this one?

@vrothberg
Copy link
Member

Could I take a shot at this one?

Sure, thank you!

@github-actions
Copy link

A friendly reminder that this issue had no activity for 30 days.

@rhatdan
Copy link
Member

rhatdan commented Jul 18, 2022

@maknop @aonoa What is the status on this?

@maknop maknop removed their assignment Jul 18, 2022
@maknop
Copy link

maknop commented Jul 18, 2022

I thought I was going to have some time to work on this but I was wrong. I'll remove myself.

rhatdan added a commit to rhatdan/podman that referenced this issue Jul 26, 2022
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]>
mheon pushed a commit to mheon/libpod that referenced this issue Aug 10, 2022
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]>
@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 20, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 20, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
4 participants