mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 10:59:59 +00:00
fix(swarm-drill): collect diagnostics when the drill is cut short by SIGTERM
The routine only carried an EXIT trap, so a run terminated by the enclosing `timeout` in distros.sh:128 left no rescue diagnostics, no playwright reports and no teardown — the exact case where the artifacts matter most. Add a TERM trap and make the handler take the status as an argument, so EXIT keeps using `$?` while TERM passes 143 explicitly. The `_teardown_done` latch is required because the EXIT trap still fires after the TERM trap; without it the whole collect-and-teardown block, including its 1500s and 900s timeouts, would run twice. This works because GNU timeout signals the whole process group: bash defers a trap while it waits on a foreground child, so a bare kill to the script PID alone would not surface it until that child exited. Reproduced under the real shape (timeout -k): TEARDOWN rc=143, exactly once, after 2.01s. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
1 parent
8222739242
commit
954b9f1ae6
1 file changed
+4
-1
@@ -63,7 +63,9 @@ if [ -n "${disable:-}" ]; then
|
||||
fi
|
||||
|
||||
collect_and_teardown() {
|
||||
rc=$?
|
||||
rc=${1:-$?}
|
||||
[ -n "${_teardown_done:-}" ] && return 0
|
||||
_teardown_done=1
|
||||
|
||||
if [ "${rc}" -ne 0 ]; then
|
||||
rescue_dir="${INFINITO_RESCUE_DIAGNOSTICS_BASE}/${INFINITO_DISTRO}/${APP_ID}"
|
||||
@@ -82,6 +84,7 @@ collect_and_teardown() {
|
||||
return "${rc}"
|
||||
}
|
||||
trap collect_and_teardown EXIT
|
||||
trap 'collect_and_teardown 143' TERM
|
||||
|
||||
# shellcheck source=scripts/tests/deploy/utils/filesystem/pick.sh
|
||||
. "${REPO_ROOT}/scripts/tests/deploy/utils/filesystem/pick.sh"
|
||||
|
||||
Reference in new issue
Block a user