From 9806ed40dfda7e996c73350fbb16e8a49533e026 Mon Sep 17 00:00:00 2001 From: Agent Date: Sat, 18 Apr 2026 07:41:05 +0000 Subject: [PATCH] =?UTF-8?q?fix:=20[nomad-step-5]=20S5.4=20=E2=80=94=20disp?= =?UTF-8?q?atcher.sh=20nomad=20exit=20code=20extraction=20(dead=20!=3D=20f?= =?UTF-8?q?ailure)=20(#991)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docker/edge/dispatcher.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/docker/edge/dispatcher.sh b/docker/edge/dispatcher.sh index 16ccb3e..282342a 100755 --- a/docker/edge/dispatcher.sh +++ b/docker/edge/dispatcher.sh @@ -683,10 +683,10 @@ _launch_runner_nomad() { # Get allocation logs logs=$(nomad alloc logs -short "$alloc_id" 2>/dev/null || true) - # Try to get exit code from JSON output - # Nomad alloc status -json has .TaskStates["].Events[].ExitCode + # Try to get exit code from alloc status JSON + # Nomad alloc status -json has .TaskStates[""].Events[].ExitCode local alloc_exit_code - alloc_exit_code=$(echo "$final_status_json" | jq -r '.TaskStates["runner"].Events[-1].ExitCode // empty' 2>/dev/null) || alloc_exit_code="" + alloc_exit_code=$(nomad alloc status -json "$alloc_id" 2>/dev/null | jq -r '.TaskStates["runner"].Events[-1].ExitCode // empty' 2>/dev/null) || alloc_exit_code="" if [ -n "$alloc_exit_code" ] && [ "$alloc_exit_code" != "null" ]; then exit_code="$alloc_exit_code" @@ -694,12 +694,14 @@ _launch_runner_nomad() { fi # If we couldn't get exit code from alloc, check job state as fallback + # Note: "dead" = terminal state for batch jobs (includes successful completion) + # Only "failed" indicates actual failure if [ "$exit_code" -eq 0 ]; then local final_state final_state=$(echo "$final_status_json" | jq -r '.Status // empty' 2>/dev/null) || final_state="" case "$final_state" in - failed|dead) + failed) exit_code=1 ;; esac