spiegel_podman/test/system/221-healthcheck-transient.bats
Jan Rodák 9598b30ac2
Fix healthcheck failing silently with --transient-store
The systemd timer created for health checks did not pass global
podman flags to the subprocess, causing it to use default storage
settings instead of matching the parent process. This is most
visible with --transient-store, where the healthcheck looks up
the container in the default store instead of the volatile one.

Extract GlobalPodmanArgs() from CreateExitCommandArgs so both the
exit command and healthcheck timer share the same set of global
flags (--root, --runroot, --transient-store, --storage-driver, etc.).

Fixes: https://github.com/containers/podman/issues/28483

Signed-off-by: Jan Rodák <hony.com@seznam.cz>
2026-04-14 14:13:20 +02:00

45 lines
1.4 KiB
Bash

#!/usr/bin/env bats -*- bats -*-
#
# tests for podman healthcheck with --transient-store
#
#
load helpers
load helpers.systemd
function teardown() {
run_podman '?' --transient-store rm -t 0 -a -f
basic_teardown
}
# https://github.com/containers/podman/issues/28483
@test "podman healthcheck --transient-store" {
skip_if_remote "transient-store is a local option"
ctr="c-h-$(safename)"
run_podman run -d --name $ctr --transient-store \
--health-cmd /home/podman/healthcheck \
--health-interval 1s \
--health-retries 3 \
$IMAGE /home/podman/pause
cid="$output"
# The systemd timer command line must include --transient-store=true so
# the healthcheck subprocess opens the correct (volatile) store.
run -0 systemctl list-units
cidmatch=$(grep "$cid" <<<"$output")
assert "$cidmatch" =~ "--transient-store=true .* healthcheck run --ignore-result $cid" \
"Healthcheck systemd unit includes --transient-store=true"
run_podman --transient-store wait --condition=healthy $ctr
run_podman --transient-store inspect $ctr \
--format "{{.State.Health.Status}} {{.State.Health.FailingStreak}}"
assert "$output" == "healthy 0" "health status and failing streak"
run_podman --transient-store rm -f -t0 $ctr
}
# vim: filetype=sh