From baa7c8a3fdc34f4e612fb7798cf080f4ca9d1ba4 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Tue, 18 Aug 2026 10:10:42 +0200 Subject: [PATCH] fix(svc-bkp-volume-2-local): let the drill start a run the last one left failed wait_service_terminated guards two opposite moments with one rule. The call before the forced backup only has to wait out a run still in flight, while the calls after a systemctl start read the verdict on the code under test. Both treated 'failed' as fatal, so a unit left failed by an earlier deploy ended the drill in the pre-flight - after 0.13s, reporting a state three hours old as if it were this run's result. That made the drill blind from its first failure onward: it could never start another backup, so every defect behind the first one stayed unreachable. The pre-flight now clears such a state and carries on. After a start of its own, 'failed' stays fatal. Co-Authored-By: Claude Opus 5 (1M context) --- roles/svc-bkp-volume-2-local/files/test/test.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/roles/svc-bkp-volume-2-local/files/test/test.sh b/roles/svc-bkp-volume-2-local/files/test/test.sh index 97ba195abf..7164030e7c 100755 --- a/roles/svc-bkp-volume-2-local/files/test/test.sh +++ b/roles/svc-bkp-volume-2-local/files/test/test.sh @@ -36,7 +36,11 @@ DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" bash "${DIR}/probe/subvolume.sh" bash "${DIR}/probe/snapshot.sh" +# Param $1: when non-empty, a unit already sitting in 'failed' is a verdict +# from an earlier deploy rather than this run's, so clear it and +# carry on instead of reporting a backup this drill never started. wait_service_terminated() { + local stale_failure_ok="${1:-}" local deadline state deadline=$(( $(date +%s) + BKP_TEST_HEALTH_TIMEOUT )) while :; do @@ -50,6 +54,11 @@ wait_service_terminated() { sleep 5 ;; failed) + if [ -n "${stale_failure_ok}" ]; then + echo "OK: clearing a 'failed' state left by an earlier run" + systemctl reset-failed "${BKP_TEST_SERVICE}" + return 0 + fi echo "FAIL: ${BKP_TEST_SERVICE} terminated in state 'failed'" systemctl status "${BKP_TEST_SERVICE}" --no-pager 2>&1 | tail -20 journalctl -u "${BKP_TEST_SERVICE}" --no-pager -n 100 2>&1 || true # nocheck: shell-or-true -- grandfathered: worked in practice; TODO: sharpen to catch only the exact tolerated error @@ -68,7 +77,7 @@ count_generations() { COUNT="${#GENERATIONS[@]}" } -wait_service_terminated +wait_service_terminated stale_failure_ok echo "Forcing a post-deploy backup run (the service-loader pre-state backup can predate the app volumes and be empty)" if ! timeout "${BKP_TEST_HEALTH_TIMEOUT}" systemctl start "${BKP_TEST_SERVICE}"; then