forked from containers/podman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rm pod with podman run if ctr creation failed
Currently, if the container creation failed with either run or create and you've used --pod with new: the pod would be created nonetheless. This change ensures the pod just created is also cleaned up in case of container creation failure Fixes containers#21228 Signed-off-by: danishprakash <danish.prakash@suse.com>
- Loading branch information
1 parent
9fed92b
commit d672ff0
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/usr/bin/env bats | ||
|
||
load helpers | ||
load helpers.network | ||
|
||
|
||
|
||
@test "podman run - rm pod if container creation failed with -pod new:" { | ||
run_podman run -d --name foobar $IMAGE hostname | ||
cid=$output | ||
|
||
podname=pod$(random_string) | ||
run_podman 125 run --rm --pod "new:$podname" --name foobar $IMAGE hostname | ||
is "$output" ".*creating container storage: the container name \"foobar\" is already in use by" | ||
|
||
# pod should've been cleaned up | ||
# if container creation failed | ||
run_podman 1 pod exists $podname | ||
|
||
run_podman rm $cid | ||
run_podman rmi $(pause_image) | ||
} |