diff options
author | Paul Holzinger <paul.holzinger@web.de> | 2021-05-11 18:41:36 +0200 |
---|---|---|
committer | Paul Holzinger <paul.holzinger@web.de> | 2021-05-11 22:37:32 +0200 |
commit | 30544f225e73a4180f4afb0d062006c9fa61a309 (patch) | |
tree | f135ce04d90289283e170aa140b4cce48ed0ac05 /test | |
parent | 8dcd5b893feb8b3b34386e6688d20b7ef098228b (diff) | |
download | podman-30544f225e73a4180f4afb0d062006c9fa61a309.tar.gz podman-30544f225e73a4180f4afb0d062006c9fa61a309.tar.bz2 podman-30544f225e73a4180f4afb0d062006c9fa61a309.zip |
fix restart always with slirp4netns
When a container is automatically restarted due its restart policy and
the container used the slirp4netns netmode, the slirp4netns process
died. This caused the container to lose network connectivity.
To fix this we have to start a new slirp4netns process.
Fixes #8047
Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
Diffstat (limited to 'test')
-rw-r--r-- | test/system/500-networking.bats | 46 |
1 files changed, 43 insertions, 3 deletions
diff --git a/test/system/500-networking.bats b/test/system/500-networking.bats index 788dc4cd1..94980346e 100644 --- a/test/system/500-networking.bats +++ b/test/system/500-networking.bats @@ -33,9 +33,10 @@ load helpers # Bind-mount this file with a different name to a container running httpd run_podman run -d --name myweb -p "$HOST_PORT:80" \ - -v $INDEX1:/var/www/index.txt \ - -w /var/www \ - $IMAGE /bin/busybox-extras httpd -f -p 80 + --restart always \ + -v $INDEX1:/var/www/index.txt \ + -w /var/www \ + $IMAGE /bin/busybox-extras httpd -f -p 80 cid=$output # In that container, create a second file, using exec and redirection @@ -67,6 +68,45 @@ load helpers run_podman 125 port myweb 99/tcp is "$output" 'Error: failed to find published port "99/tcp"' + # Tests #10310: podman will restart slirp4netns on container restart + run_podman container inspect --format "{{.State.Pid}}" $cid + pid=$output + + # Kill the process; podman restart policy will bring up a new container. + # -9 is crucial: busybox httpd ignores all other signals. + kill -9 $pid + # Wait for process to exit + retries=30 + while kill -0 $pid; do + sleep 0.5 + retries=$((retries - 1)) + if [[ $retries -eq 0 ]]; then + die "Process $pid (container $cid) refused to die" + fi + done + + # Wait for container to restart + retries=20 + while :;do + run_podman '?' container inspect --format "{{.State.Pid}}" myweb + if [[ $status -eq 0 ]]; then + if [[ $output == $pid ]]; then + die "This should never happen! Restarted container has same PID ($output) as killed one!" + fi + break + fi + sleep 0.5 + retries=$((retries - 1)) + if [[ $retries -eq 0 ]]; then + die "Timed out waiting for container to restart" + fi + done + + # Verify http contents again: curl from localhost + # Use retry since it can take a moment until the new container is ready + run curl --retry 2 -s $SERVER/index.txt + is "$output" "$random_1" "curl 127.0.0.1:/index.txt after restart" + # Clean up run_podman stop -t 1 myweb run_podman rm myweb |