From 81fceb48d2f2f7c28a4c0e27c8acf65f9b50a51a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Rod=C3=A1k?= Date: Thu, 4 Jun 2026 16:11:54 +0200 Subject: [PATCH] Fix healthcheck flake by capturing time before systemctl checks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After _check_health "First failure" returns with FailingStreak=2, the 3rd failure fires during the subsequent systemctl checks (~1s interval), emitting the "unhealthy" event before current_time was captured. Move current_time before those checks so --since doesn't miss the event. Signed-off-by: Jan Rodák --- test/system/220-healthcheck.bats | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/system/220-healthcheck.bats b/test/system/220-healthcheck.bats index 200bad33bf..b2b3c90ab8 100644 --- a/test/system/220-healthcheck.bats +++ b/test/system/220-healthcheck.bats @@ -96,6 +96,10 @@ Log[-1].ExitCode | 1 Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\\\n\" " "$current_time" "healthy" + # Capture time before systemctl checks so we don't miss the "unhealthy" + # event that may fire during those checks (health-interval is only 1s). + current_time=$(date --iso-8601=ns) + # Check that we now we do have valid podman units with this # name so that the leak check below does not turn into a NOP without noticing. run -0 systemctl list-units @@ -110,7 +114,6 @@ Log[-1].Output | \"Uh-oh on stdout!\\\nUh-oh on stderr!\\\n\" 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) # After three successive failures, container should no longer be healthy _check_health $ctrname "Four or more failures" " Status | \"unhealthy\"