diff --git a/libpod/healthcheck_linux.go b/libpod/healthcheck_linux.go index b0be18564a..e0396e1040 100644 --- a/libpod/healthcheck_linux.go +++ b/libpod/healthcheck_linux.go @@ -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") diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index 32a6f5122f..7ad946c604 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -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" "