Skip to content

fix: remote() SSH retry loop was dead code under set -e - #6

Open
adjarteyo-zs wants to merge 1 commit into
mainfrom
fix/remote-retry-under-errexit
Open

adjarteyo-zs wants to merge 1 commit into
mainfrom
fix/remote-retry-under-errexit

Conversation

@adjarteyo-zs

Copy link
Copy Markdown
Contributor

Summary

  • `remote()` in `build-private-network.sh` retries on ssh exit 255 (transient connection failure), but for any call site that invokes it as a bare statement, `set -e` aborted the whole script on the first failure before the retry loop's `status=$?` line ever ran. Confirmed against this file's actual call sites: 9 of 16 are bare statements (`netplan apply`, `tailscale up`, the Headscale/Headplane config sed lines, etc.) and were genuinely affected; the remaining 7 (an `until` condition, and command substitutions ending `|| true`) already worked correctly since bash suspends errexit in those positions regardless.
  • Fix: wrap the `ssh` call in `set +e`/`set -e` so the retry loop actually runs for every call site, not just the ones already in an exempted position.
  • Found while reusing this function as the template for Tutorial 2's storage script (same bug ported there too, fixed independently on that branch). Doesn't touch any other logic.

Test plan

  • `bash -n` passes
  • Reproduced the bug and the fix against isolated test scripts mirroring this file's real call-site patterns (bare statement, `until` condition, `$(... || true)` substitution)
  • Next live run of `build-private-network.sh` (planned as part of Tutorial 2 testing) will exercise this path against real infrastructure

🤖 Generated with Claude Code

https://claude.ai/code/session_01GYDuX3maSmsGpSzcWaqCGW

A bare failing ssh call inside the function aborted the whole script
via errexit before status=$? on the next line ever ran, so the retry
loop never actually executed for any call site. Wrap the ssh call in
set +e / set -e so the retry logic (and the final status propagation)
works as intended.

Co-Authored-By: Claude Sonnet 5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01GYDuX3maSmsGpSzcWaqCGW
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Advanced

Run ID: 5cae719e-a845-4cfc-b014-0538e0fb6c86


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants