Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/2791-deploy-guard-target-sha.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- **Termux native worker deploy: `--target-sha` no longer breaks the rollout guard (#2791).** `run_guard` built the guard's environment with `${TARGET_SHA:+A2A_WORKER_TARGET_REVISION=…} node …`; an assignment produced by an expansion is not an assignment to bash, so every run with `--target-sha` and a shipped `worker-artifact-rollout-guard.mjs` ran `A2A_WORKER_TARGET_REVISION=…` as the command and failed (rc 127 → exit 20, nothing changed). Found by the first live dry-run on a Termux node; the guard now gets its variables through `env`. New tests (mutation-checked against the old line) cover a shipped guard with `--target-sha`.
7 changes: 5 additions & 2 deletions scripts/a2a-termux-native-worker-deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -307,8 +307,11 @@ run_guard() { # <root>: the artifact's own rollout guard, when it ships one
local root="${1:-$ROOT}" guard out
guard="$root/scripts/worker-artifact-rollout-guard.mjs"
(( GUARD )) && [[ -f "$guard" ]] || return 0
out=$(A2A_WORKER_ROOT="$root" ${TARGET_SHA:+A2A_WORKER_TARGET_REVISION="$TARGET_SHA"} \
node "$guard" --deployed 2>&1) || { say "guard rc!=0: ${out##*$'\n'}"; return 1; }
# The assignments go through `env`: an assignment produced by an expansion is not an assignment to bash,
# so `${TARGET_SHA:+VAR=...} node` ran "VAR=..." as the command (rc 127 on every --target-sha run).
local -a envs=("A2A_WORKER_ROOT=$root")
[[ -n "$TARGET_SHA" ]] && envs+=("A2A_WORKER_TARGET_REVISION=$TARGET_SHA")
out=$(env "${envs[@]}" node "$guard" --deployed 2>&1) || { say "guard rc!=0: ${out##*$'\n'}"; return 1; }
python3 - "$out" <<'PY'
import json, sys
s = sys.argv[1]
Expand Down
10 changes: 9 additions & 1 deletion scripts/a2a-termux-native-worker-deploy.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ chmod +x "$TMP/fake-harness.sh"
mkdir -p "$TMP/bin"
cat > "$TMP/bin/node" <<EOF
#!/usr/bin/env bash
echo "guard: \$* root=\${A2A_WORKER_ROOT:-}" >> "$TMP/node.calls"
echo "guard: \$* root=\${A2A_WORKER_ROOT:-} target=\${A2A_WORKER_TARGET_REVISION:-}" >> "$TMP/node.calls"
cat "$TMP/guard.out" 2>/dev/null || echo '{"ok":true}'
EOF
chmod +x "$TMP/bin/node"
Expand Down Expand Up @@ -163,6 +163,14 @@ ok "dry-run guard runs --deployed against the preview root" \
fresh; echo '{"ok":false}' > "$TMP/guard.out"
out=$(deploy --artifact "$ART" --no-guard); rc=$?
ok "dry-run --no-guard skips the shipped guard" '[ "$rc" = 0 ] && [ ! -e "$TMP/node.calls" ] && grep -q "guard=off" <<<"$out"'
# A shipped guard together with --target-sha (the way an operator runs a real rollout): the guard gets the target
# revision in its environment. Before this fix the assignment ran as the command (rc 127 on every such run).
fresh; : > "$ART/scripts/worker-artifact-rollout-guard.mjs"
out=$(deploy --artifact "$ART" --target-sha "$NEW_SHA"); rc=$?
ok "dry-run guard + --target-sha: the guard runs and passes" \
'[ "$rc" = 0 ] && grep -q "DRY-RUN OK" <<<"$out" && ! grep -q "command not found" <<<"$out"'
ok "dry-run guard + --target-sha: the guard sees the target revision" \
'grep -q -- "--deployed root=$TMP/stagetmp/.* target=$NEW_SHA\$" "$TMP/node.calls"'
rm -f "$ART/scripts/worker-artifact-rollout-guard.mjs"

# A symlinked live dist/ (release-dir layout) must not let the preview overlay
Expand Down
Loading