Merge pull request #27330 from winterqt/push-pwouqluolwxt

libpod: fix healthchecks not executing every interval on linux
This commit is contained in:
Paul Holzinger
2025-12-12 18:15:05 +01:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -40,7 +40,8 @@ func (c *Container) createTimer(interval string, isStartup bool) error {
cmd = append(cmd, "--setenv=PATH="+path)
}
cmd = append(cmd, "--unit", hcUnitName, fmt.Sprintf("--on-unit-inactive=%s", interval), "--timer-property=AccuracySec=1s", podman)
// StartLimitIntervalSec=0 so we don't hit the restart limit
cmd = append(cmd, "--unit", hcUnitName, fmt.Sprintf("--on-unit-inactive=%s", interval), "--timer-property=AccuracySec=1s", "--property=StartLimitIntervalSec=0", podman)
if logrus.IsLevelEnabled(logrus.DebugLevel) {
cmd = append(cmd, "--log-level=debug", "--syslog")

View File

@@ -104,6 +104,11 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\\\n\"
assert "$cidmatch" =~ " $cid-[0-9a-f]+\.timer *.*/podman healthcheck run $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"
assert "$output" =~ "StartLimitIntervalUSec=0" "The hc service has the right interval set"
current_time=$(date --iso-8601=ns)
# After three successive failures, container should no longer be healthy
_check_health $ctrname "Four or more failures" "