Skip to content

Commit 5733ee3

Browse files
Spencer Bryngelsonclaude
andcommitted
fix: address all PR review findings in runner scripts
- frontier/deploy-runners.sh: pre-download tarball once before spawning parallel make-runner.sh instances; use atomic tmp+mv to prevent concurrent curl writes corrupting the tarball - frontier/make-runner.sh: same atomic tmp+mv for solo-invocation safety - common/rerun-failed.sh: guard gh run view with || continue so an expired/deleted run skips rather than exits the whole script; switch pipe loops to process substitution so continue works correctly and remove the dead rerun_count variable (incremented in a subshell, never read) - frontier/list-runners.sh, phoenix/list-runners.sh, restart-all.sh, rebalance-runners.sh: replace for dir in $(find_runner_dirs) with while IFS= read -r dir; do ... done < <(find_runner_dirs) to eliminate word-splitting and glob expansion on runner paths - phoenix/check-runners.sh, phoenix/list-runners.sh: guard rss value before arithmetic expansion — if SSH fails and rss="?", the expression $(( CGROUP_LIMIT - rss )) is a syntax error that exits under set -euo pipefail; default to 0 instead Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent c190646 commit 5733ee3

8 files changed

Lines changed: 37 additions & 19 deletions

File tree

misc/common/rerun-failed.sh

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ if [ -z "$prs" ]; then
2222
exit 0
2323
fi
2424

25-
rerun_count=0
2625
for pr in $prs; do
2726
title=$(gh pr view --repo "$REPO" "$pr" --json title --jq .title)
2827
branch=$(gh pr view --repo "$REPO" "$pr" --json headRefName --jq .headRefName)
@@ -35,21 +34,21 @@ for pr in $prs; do
3534
if [ -n "$failed_runs" ]; then
3635
echo ""
3736
echo "=== PR #$pr: $title ==="
38-
echo "$failed_runs" | while read -r run_id run_name; do
39-
# Check which jobs failed
37+
while read -r run_id run_name; do
38+
# Check which jobs failed; skip if run has expired or been deleted
4039
failed_jobs=$(gh run view --repo "$REPO" "$run_id" \
41-
--json jobs --jq '.jobs[] | select(.conclusion == "failure" or .conclusion == "cancelled") | .name')
40+
--json jobs --jq '.jobs[] | select(.conclusion == "failure" or .conclusion == "cancelled") | .name' \
41+
2>/dev/null) || { echo " WARNING: could not fetch jobs for run $run_id, skipping"; continue; }
4242
echo " Run $run_id ($run_name):"
43-
echo "$failed_jobs" | while read -r job; do
43+
while read -r job; do
4444
echo " - $job"
45-
done
45+
done <<< "$failed_jobs"
4646

4747
if [ "${APPLY:-0}" = "1" ]; then
4848
echo " Rerunning failed jobs..."
4949
gh run rerun --repo "$REPO" "$run_id" --failed || echo " WARNING: rerun failed (may already be rerunning)"
50-
rerun_count=$((rerun_count + 1))
5150
fi
52-
done
51+
done < <(echo "$failed_runs")
5352
fi
5453
done
5554

@@ -60,13 +59,13 @@ master_failed=$(gh run list --repo "$REPO" --branch master --limit 5 \
6059
--json databaseId,status,conclusion,name \
6160
--jq '.[] | select(.conclusion == "failure") | "\(.databaseId) \(.name)"')
6261
if [ -n "$master_failed" ]; then
63-
echo "$master_failed" | while read -r run_id run_name; do
62+
while read -r run_id run_name; do
6463
echo " Run $run_id ($run_name)"
6564
if [ "${APPLY:-0}" = "1" ]; then
6665
echo " Rerunning failed jobs..."
6766
gh run rerun --repo "$REPO" "$run_id" --failed || echo " WARNING: rerun failed"
6867
fi
69-
done
68+
done < <(echo "$master_failed")
7069
else
7170
echo " All passing"
7271
fi

misc/frontier/deploy-runners.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,21 @@ if [ ${#TARGET_NODES[@]} -eq 0 ]; then
1818
exit 1
1919
fi
2020

21+
# Pre-download the runner tarball once before spawning parallel make-runner.sh
22+
# instances. Without this, all instances race to download the same file
23+
# concurrently and corrupt it. The tmp+mv ensures an atomic final placement.
24+
RUNNER_VERSION="${RUNNER_VERSION:-$(gh_latest_runner_version 2>/dev/null || echo "2.332.0")}"
25+
TARBALL="actions-runner-linux-x64-${RUNNER_VERSION}.tar.gz"
26+
if [ ! -f "${SHARED_DIR}/${TARBALL}" ]; then
27+
echo "==> Downloading runner v${RUNNER_VERSION}..."
28+
tmp="${SHARED_DIR}/${TARBALL}.tmp.$$"
29+
curl -fsSL \
30+
"https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/${TARBALL}" \
31+
-o "$tmp"
32+
mv "$tmp" "${SHARED_DIR}/${TARBALL}"
33+
fi
34+
export RUNNER_VERSION
35+
2136
for i in "${!TARGET_NODES[@]}"; do
2237
NODE="${TARGET_NODES[$i]}"
2338
NUM=$((START_NUM + i))

misc/frontier/list-runners.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ done < <(gh_list_runners)
5454
printf "%-25s %-8s %-14s %s\n" "NAME" "GITHUB" "NODE" "RSS"
5555
printf "%s\n" "$(printf '%.0s-' {1..60})"
5656

57-
for dir in $(find_runner_dirs); do
57+
while IFS= read -r dir; do
5858
name=$(get_runner_name "$dir")
5959
[ -z "$name" ] && continue
6060

@@ -86,4 +86,4 @@ for dir in $(find_runner_dirs); do
8686
fi
8787

8888
printf "%-25s %-8s %-14s %sMB\n" "$name" "$gh_col" "$node_col" "$rss"
89-
done
89+
done < <(find_runner_dirs)

misc/frontier/make-runner.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,11 @@ echo "==> Setting up runner: ${RUNNER_NAME} on ${TARGET_NODE}"
2424
# --- Download tarball once to shared dir ---
2525
if [ ! -f "${SHARED_DIR}/${TARBALL}" ]; then
2626
echo "==> Downloading runner v${RUNNER_VERSION}..."
27+
tmp="${SHARED_DIR}/${TARBALL}.tmp.$$"
2728
curl -fsSL \
2829
"https://github.com/actions/runner/releases/download/v${RUNNER_VERSION}/${TARBALL}" \
29-
-o "${SHARED_DIR}/${TARBALL}"
30+
-o "$tmp"
31+
mv "$tmp" "${SHARED_DIR}/${TARBALL}"
3032
fi
3133

3234
# --- Extract (filesystem is shared across all nodes) ---

misc/phoenix/check-runners.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ for node in "${NODES[@]}"; do
2828
' 2>/dev/null || echo " (unreachable)"
2929

3030
rss=$(ssh -o ConnectTimeout=5 "$node" "ps -u \$(whoami) -o rss= 2>/dev/null | awk '{sum+=\$1} END {printf \"%.0f\", sum/1024}'" 2>/dev/null || echo "?")
31+
[[ "$rss" =~ ^[0-9]+$ ]] || rss=0
3132
echo " --- Total: ${rss} MB / ${CGROUP_LIMIT} MB ($(( CGROUP_LIMIT - rss )) MB free) ---"
3233
echo ""
3334
done

misc/phoenix/list-runners.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ while read -r id name status busy; do
2222
done <<< "$(gh_list_runners)"
2323

2424
# Walk local runner directories and cross-reference
25-
for dir in $(find_runner_dirs); do
25+
while IFS= read -r dir; do
2626
name=$(get_runner_name "$dir")
2727
[ -z "$name" ] && continue
2828

@@ -61,12 +61,13 @@ for dir in $(find_runner_dirs); do
6161

6262
printf "%-25s %-8s %-22s %-8s %5sMB %s\n" \
6363
"$name" "$gh_col" "$node" "$slurm" "$rss" "$dir"
64-
done
64+
done < <(find_runner_dirs)
6565

6666
echo ""
6767
echo "=== Per-node memory ==="
6868
for node in "${NODES[@]}"; do
6969
count=$(ssh -o ConnectTimeout=5 "$node" "ps aux | grep Runner.Listener | grep -v grep | wc -l" 2>/dev/null || echo 0)
7070
rss=$(ssh -o ConnectTimeout=5 "$node" "ps -u \$(whoami) -o rss= 2>/dev/null | awk '{sum+=\$1} END {printf \"%.0f\", sum/1024}'" 2>/dev/null || echo "?")
71+
[[ "$rss" =~ ^[0-9]+$ ]] || rss=0
7172
echo " $node: $count runners, ${rss} MB / ${CGROUP_LIMIT} MB ($(( CGROUP_LIMIT - rss )) MB free)"
7273
done

misc/phoenix/rebalance-runners.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@ source "$SCRIPT_DIR/config.sh"
1515

1616
# Discover runners
1717
declare -a dirs=() names=()
18-
for dir in $(find_runner_dirs); do
18+
while IFS= read -r dir; do
1919
name=$(get_runner_name "$dir")
2020
[ -z "$name" ] && continue
2121
dirs+=("$dir")
2222
names+=("$name")
23-
done
23+
done < <(find_runner_dirs)
2424

2525
num_nodes=${#NODES[@]}
2626
num_runners=${#dirs[@]}

misc/phoenix/restart-all.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ source "$SCRIPT_DIR/config.sh"
1515
echo "=== Discovering runners ==="
1616
declare -a restart_list=()
1717

18-
for dir in $(find_runner_dirs); do
18+
while IFS= read -r dir; do
1919
name=$(get_runner_name "$dir")
2020
[ -z "$name" ] && continue
2121
node=$(find_node "$dir")
@@ -37,7 +37,7 @@ for dir in $(find_runner_dirs); do
3737
fi
3838

3939
restart_list+=("$node $dir $name")
40-
done
40+
done < <(find_runner_dirs)
4141

4242
if [ ${#restart_list[@]} -eq 0 ]; then
4343
echo "Nothing to restart."

0 commit comments

Comments
 (0)