mirror of
https://github.com/containers/podman.git
synced 2026-03-13 08:01:19 +08:00
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 <patrick.wicki@siemens.com>
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user