From dc1b0ada0af5e07ad8480523e937126b27357769 Mon Sep 17 00:00:00 2001 From: mforce Date: Sun, 13 Sep 2026 23:39:37 +0000 Subject: [PATCH] fix(sim): stop the k6-baseline EXIT trap masking a clean run as failed kill -TERM on the already-reaped sampler_pid failed under set -e inside the trap, which silently replaced an explicit `exit 0` with exit 1 even when every rep was clean. --- tools/simulation/run-baseline.sh | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tools/simulation/run-baseline.sh b/tools/simulation/run-baseline.sh index dd06425e9..e213f2979 100755 --- a/tools/simulation/run-baseline.sh +++ b/tools/simulation/run-baseline.sh @@ -288,8 +288,13 @@ overall_exit=0 # below; this trap is the backstop for every OTHER exit path. Single-quoted # so `$sampler_pid` is read at trap-FIRE time (whichever rep was most # recently started), not at registration time — one registration here -# correctly covers every rep in the loop. -trap 'kill -TERM "${sampler_pid:-}" 2>/dev/null; wait "${sampler_pid:-}" 2>/dev/null || true' EXIT +# correctly covers every rep in the loop. `kill` needs its own `|| true`: +# on the ordinary happy path the sampler was already reaped by the per-rep +# cleanup below, so this `kill` finds no such process and fails — and +# because `set -e` is still active while a trap runs, that failure aborts +# the trap right there and silently replaces the script's real exit code +# with 1, even after an explicit `exit 0` already ran. +trap 'kill -TERM "${sampler_pid:-}" 2>/dev/null || true; wait "${sampler_pid:-}" 2>/dev/null || true' EXIT if [[ -n "$RENDER_ONLY_RUN_ID" ]]; then echo "[render-only] skipping reset/docker/k6/monitoring — re-aggregating existing rep-*/ data under ${RUN_DIR}"