From 2828965a7524fc754f16f2b1425fe0065191e11f Mon Sep 17 00:00:00 2001 From: Patrick Wicki Date: Fri, 6 Feb 2026 16:21:16 +0100 Subject: [PATCH] healthcheck_linux: avoid failing transient units The main purpose of the transient services/timers is to trigger the healthcheck execution in regular intervals, their own state should not depend on the result of the healthchecks. This way there are no failing systemd services unless there is actually a fatal error. Signed-off-by: Patrick Wicki --- libpod/healthcheck_linux.go | 2 +- test/system/220-healthcheck.bats | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/libpod/healthcheck_linux.go b/libpod/healthcheck_linux.go index e0396e1040..49f4f329ee 100644 --- a/libpod/healthcheck_linux.go +++ b/libpod/healthcheck_linux.go @@ -47,7 +47,7 @@ func (c *Container) createTimer(interval string, isStartup bool) error { cmd = append(cmd, "--log-level=debug", "--syslog") } - cmd = append(cmd, "healthcheck", "run", c.ID()) + cmd = append(cmd, "healthcheck", "run", "--ignore-result", c.ID()) conn, err := systemd.ConnectToDBUS() if err != nil { diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index 74d263897c..20459a7cd6 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -101,12 +101,13 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\\\n\" run -0 systemctl list-units cidmatch=$(grep "$cid" <<<"$output") echo "$cidmatch" - assert "$cidmatch" =~ " $cid-[0-9a-f]+\.timer *.*/podman healthcheck run $cid" \ + assert "$cidmatch" =~ " $cid-[0-9a-f]+\.timer *.*/podman healthcheck run --ignore-result $cid" \ "Healthcheck systemd unit exists" # Check that the right service option is applied so we don't hit the systemd restart limit. # Even though the code sets StartLimitIntervalSec the systemd command prints StartLimitInterval*U*Sec - run -0 systemctl show "$cid-*.service" + # Use show --all otherwise the glob might not match the already inactive transient unit. + run -0 systemctl show --all "$cid-*.service" assert "$output" =~ "StartLimitIntervalUSec=0" "The hc service has the right interval set" current_time=$(date --iso-8601=ns)