mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-29 06:17:25 +00:00
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) <noreply@anthropic.com>
This commit is contained in:
1 parent
5465b9aa33
commit
baa7c8a3fd
1 file changed
+10
-1
@@ -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
|
||||
|
||||
Reference in new issue
Block a user