#!/usr/bin/env bats -*- bats -*- # # test to make sure we use the correct podman pause process # load helpers load helpers.registry load helpers.sig-proxy function setup_file() { # We have to stop the background registry here. These tests kill the podman pause # process which means commands after that are in a new one and when the cleanup # later tries to stop the registry container it will be in the wrong ns and can fail. # https://github.com/containers/podman/pull/21563#issuecomment-1960047648 stop_registry } function _check_pause_process() { # do not mark these variables as local; our caller expects them pause_pid_file="$XDG_RUNTIME_DIR/libpod/tmp/pause.pid" ns_handles_file="$XDG_RUNTIME_DIR/libpod/tmp/ns_handles" pause_pid="" # Check that either ns_handles or pause.pid exists if [ -e $ns_handles_file ]; then # ns_handles file exists, no pause process needed return fi test -e $pause_pid_file || die "Neither ns_handles file ($ns_handles_file) nor pause.pid file ($pause_pid_file) exists" pause_pid=$(<$pause_pid_file) test -d /proc/$pause_pid || die "Pause process $pause_pid (from $pause_pid_file) is not running" assert "$( $pause_pid_file run_podman info assert "$output" =~ "pause.pid file refers to PID $fake_pid which is not a pause process" \ "podman should report stale pause.pid" assert "$output" =~ "Removing.*pause.pid" \ "podman should report removing the stale pause.pid file" kill $fake_pid 2>/dev/null || true _check_pause_process } # regression test for https://issues.redhat.com/browse/RHEL-59620 @test "rootless userns can unmount netns properly" { skip_if_not_rootless "pause process is only used as rootless" skip_if_remote "system migrate not supported via remote" # Use podman system migrate to stop the currently running pause process run_podman system migrate # First run a container with a custom userns as this uses different netns setup logic. local cname=c-$(safename) run_podman run --userns keep-id --name $cname -d $IMAGE sleep 100 # Now run a "normal" container without userns run_podman run --rm $IMAGE true # This used to hang trying to unmount the netns. run_podman rm -f -t0 $cname } # regression test for https://issues.redhat.com/browse/RHEL-130252 @test "podman system migrate works with conmon being killed" { skip_if_not_rootless "pause process is only used as rootless" skip_if_remote "system migrate not supported via remote" local cname=c-$(safename) run_podman run --name $cname --stop-signal SIGKILL -d $IMAGE sleep 100 run_podman inspect --format '{{.State.ConmonPid}}' $cname conmon_pid="$output" # Check for pause pid or ns_handles file, and remove/kill it # Note: _check_pause_process sets ns_handles_file and pause_pid _check_pause_process if [ -e $ns_handles_file ]; then rm -f $ns_handles_file elif [ -n "$pause_pid" ]; then kill -9 $pause_pid fi # kill conmon kill -9 $conmon_pid # Use podman system migrate to stop the currently running pause process run_podman 125 system migrate assert "$output" =~ "Failed to join existing conmon namespace" "fallback to userns creating" assert "$output" =~ "conmon process killed" # Now the removal command should work fine without errors. run_podman rm $cname }