-
Notifications
You must be signed in to change notification settings - Fork 2
fix: treat failed Nomad allocations as completed #401
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,13 +41,14 @@ function get_status() { | |
| echo "$client_status" | ||
| } | ||
|
|
||
| # See https://developer.hashicorp.com/nomad/commands/job/status#running | ||
| function is_running() { | ||
| local status="$1" | ||
| case "$status" in | ||
| complete|failed|lost|stopped|dead|unknown) | ||
| return 1 ;; # not running | ||
| running) | ||
| return 0 ;; # still running | ||
| *) | ||
| return 0 ;; # still running (e.g., pending, running) | ||
| return 1 ;; # not running | ||
| esac | ||
| } | ||
|
|
||
|
|
@@ -114,18 +115,16 @@ function wait_for_job() { | |
| continue | ||
| fi | ||
|
|
||
| # Job has completed | ||
| # Job has completed at this point, either successfully or failed. | ||
| if is_run_success "$status"; then | ||
| break | ||
| echo "Scenario $scenario_name ($alloc_id) completed successfully in $ELAPSED_SECS seconds." | ||
| return 0 | ||
| else | ||
| echo "Scenario $scenario_name ($alloc_id) finished with status=$status after $ELAPSED_SECS seconds." | ||
| print_failed_tasks_and_logs "$alloc_id" "$nomad_status" | ||
| return 1 | ||
| fi | ||
|
|
||
| echo "Scenario $scenario_name ($alloc_id) failed (status=$status) after $ELAPSED_SECS seconds." | ||
| print_failed_tasks_and_logs "$alloc_id" "$nomad_status" | ||
| exit 1 | ||
| done | ||
| echo "Scenario $scenario_name ($alloc_id) completed successfully in $ELAPSED_SECS seconds." | ||
|
|
||
| return 0 | ||
| } | ||
|
|
||
|
|
||
|
|
@@ -148,13 +147,26 @@ SCENARIO_NAME="$1" | |
|
|
||
| shift # Remove the first argument (scenario name) | ||
|
|
||
| # Count total number of allocations and track failures | ||
| TOTAL_ALLOCATIONS=$# | ||
| FAILED_ALLOCATIONS=0 | ||
|
|
||
| # Process each allocation ID passed as arguments | ||
| while [[ $# -gt 0 ]]; do | ||
| # Get next allocation ID from arguments | ||
| alloc_id="$1" | ||
| wait_for_job "$SCENARIO_NAME" "$alloc_id" | ||
|
|
||
| if ! wait_for_job "$SCENARIO_NAME" "$alloc_id"; then | ||
| FAILED_ALLOCATIONS=$((FAILED_ALLOCATIONS + 1)) | ||
| fi | ||
|
|
||
| shift # Remove the processed allocation ID | ||
| done | ||
|
|
||
| # If all allocations failed, exit with error | ||
| if [[ $FAILED_ALLOCATIONS -eq $TOTAL_ALLOCATIONS ]]; then | ||
| echo "Error: All $TOTAL_ALLOCATIONS allocation(s) failed." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
coderabbitai[bot] marked this conversation as resolved.
Show resolved
Hide resolved
Comment on lines
+166
to
+171
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: find . -name "ci_allocs.sh" -o -name "wait_for_jobs.sh" 2>/dev/null | head -20Repository: holochain/wind-tunnel Length of output: 126 🏁 Script executed: cat nomad/scripts/ci_allocs.sh | head -100Repository: holochain/wind-tunnel Length of output: 3424 🏁 Script executed: grep -n "peer_end_count\|peer_count\|ClientStatus\|failed.*alloc" nomad/scripts/ci_allocs.sh -A 3 -B 3Repository: holochain/wind-tunnel Length of output: 656 🏁 Script executed: grep -n "make_allocs_csv\|generate_run_summary" nomad/scripts/ci_allocs.sh -A 10 -B 5Repository: holochain/wind-tunnel Length of output: 1446 🏁 Script executed: grep -n "make_allocs_csv\|alloc_ids" nomad/scripts/wait_for_jobs.sh -A 5 -B 5Repository: holochain/wind-tunnel Length of output: 369 🏁 Script executed: sed -n '146,180p' nomad/scripts/wait_for_jobs.shRepository: holochain/wind-tunnel Length of output: 735 🏁 Script executed: rg "wait_for_jobs" --type sh -A 5 -B 5 | head -80Repository: holochain/wind-tunnel Length of output: 47 🏁 Script executed: grep -rn "wait_for_jobs\|nomad/scripts/wait_for_jobs.sh" . --include="*.sh" --include="*.nomad" 2>/dev/null | head -20Repository: holochain/wind-tunnel Length of output: 47 🏁 Script executed: find . -name "*.nomad" -o -name "*.hcl" 2>/dev/null | xargs grep -l "wait_for_jobs" 2>/dev/nullRepository: holochain/wind-tunnel Length of output: 49 🏁 Script executed: cat nomad/scripts/wait_for_jobs.shRepository: holochain/wind-tunnel Length of output: 4779 🏁 Script executed: grep -rn "make_allocs_csv\|generate_run_summary" . --include="*.sh" --include="*.nomad" 2>/dev/null | grep -v "Binary"Repository: holochain/wind-tunnel Length of output: 574 🏁 Script executed: sed -n '25,50p' nomad/scripts/ci_allocs.shRepository: holochain/wind-tunnel Length of output: 980 🏁 Script executed: grep -rn "make_allocs_csv\|alloc_ids" . --include="*.sh" -B 10 -A 2 | grep -A 15 "make_allocs_csv"Repository: holochain/wind-tunnel Length of output: 2840 🏁 Script executed: grep -rn "wait_for_jobs\|make_allocs_csv" . --include="*.sh" --include="*.yml" --include="*.yaml" 2>/dev/null | grep -v "Binary"Repository: holochain/wind-tunnel Length of output: 772 🏁 Script executed: sed -n '155,170p' .github/workflows/nomad.yamlRepository: holochain/wind-tunnel Length of output: 799 🏁 Script executed: sed -n '125,160p' .github/workflows/nomad.yamlRepository: holochain/wind-tunnel Length of output: 1850 Orchestration does not filter failed allocations; peer_end_count is set statically from config. The risk scenario in your review is valid. In The allocation IDs passed to The script's assumption that the downstream summarizer will detect partial failures via 🤖 Prompt for AI Agents |
||
| exit 0 | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
is_running()function should treat "pending" as an active state.Nomad allocations can have a ClientStatus of "pending", which represents allocations waiting to be scheduled on a client node. The official Nomad documentation shows examples of allocations with DesiredStatus="run" and ClientStatus="pending" as valid intermediate states.
The current implementation only returns
0for "running", treating "pending" allocations as not running. This causes:is_run_success("pending")returnsfalseHashiCorp's own documentation recommends filtering for allocations with ClientStatus of "running" or "pending", which contradicts the current implementation that only checks "running".
Update the function to handle both states:
🤖 Prompt for AI Agents