@@ -874,16 +874,14 @@ EOF
874
874
# Test for https://github.com/containers/podman/issues/18615
875
875
@test " podman network cleanup --userns + --restart" {
876
876
skip_if_cgroupsv1 " run --uidmap fails on cgroups v1 (issue 15025, wontfix)"
877
- userns=" --userns=keep-id"
878
- if ! is_rootless; then
879
- userns=" --uidmap=0:1111111:65536 --gidmap=0:1111111:65536"
880
- fi
881
877
882
878
local net1=a-$( random_string 10)
883
879
# use /29 subnet to limit available ip space, a 29 gives 5 usable addresses (6 - 1 for the gw)
884
880
local subnet=" $( random_rfc1918_subnet) .0/29"
885
881
run_podman network create --subnet $subnet $net1
886
- local cname=con-$( random_string 10)
882
+ local cname=con1-$( random_string 10)
883
+ local cname2=con2-$( random_string 10)
884
+ local cname3=
887
885
888
886
local netns_count=
889
887
if ! is_rootless; then
@@ -896,18 +894,31 @@ EOF
896
894
897
895
# Previously this would fail as the container would run out of ips after 5 restarts.
898
896
run_podman inspect --format " {{.RestartCount}}" $cname
899
- assert " $output " == " 6" " RestartCount for failing container"
897
+ assert " $output " == " 6" " RestartCount for failing container with bridge network "
900
898
901
899
# Now make sure we can still run a container with free ips.
902
900
run_podman run --rm --network $net1 $IMAGE true
903
901
904
- if ! is_rootless; then
902
+ # And now because of all the fun we have to check the same with slirp4netns and pasta because
903
+ # that uses slighlty different code paths. Note this would dealock before the fix.
904
+ # https://github.com/containers/podman/issues/21477
905
+ run_podman 1 run --name $cname2 --network slirp4netns --restart on-failure:2 --userns keep-id $IMAGE false
906
+ run_podman inspect --format " {{.RestartCount}}" $cname2
907
+ assert " $output " == " 2" " RestartCount for failing container with slirp4netns"
908
+
909
+ if is_rootless; then
910
+ # pasta can only run rootless
911
+ cname3=con3-$( random_string 10)
912
+ run_podman 1 run --name $cname3 --network pasta --restart on-failure:2 --userns keep-id $IMAGE false
913
+ run_podman inspect --format " {{.RestartCount}}" $cname3
914
+ assert " $output " == " 2" " RestartCount for failing container with pasta"
915
+ else
905
916
# This is racy if other programs modify /run/netns while the test is running.
906
917
# However I think the risk is minimal and I think checking for this is important.
907
918
assert " $( ls /run/netns | wc -l) " == " $netns_count " " /run/netns has no leaked netns files"
908
919
fi
909
920
910
- run_podman rm -f -t0 $cname
921
+ run_podman rm -f -t0 $cname $cname2 $cname3
911
922
run_podman network rm $net1
912
923
}
913
924
0 commit comments