Skip to content

Fail fast on unreachable peers and report them after the results - #28

Merged
lydakis merged 4 commits into
mainfrom
claude/unreachable-peers-7euj2l
Oct 5, 2026
Merged

lydakis merged 4 commits into
mainfrom
claude/unreachable-peers-7euj2l

Conversation

@lydakis

@lydakis lydakis commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Requested by George · project thread

Before: with one peer offline, errand ps, df and workspaces sat for the whole timeout before printing anything: about 15s for ps and workspaces (the control request budget) and about 30s for df (Go's default dial timeout, under a 2 minute storage budget). errand run --on an offline peer waited about 30s too. SSH peers waited for the system TCP timeout. The failure line said things like context deadline exceeded or EOF, and it came before the table.

After: an offline Tailscale node fails in about 0.3s with unreachable: Tailscale reports cabal offline, last seen 3h ago, whether the peer is reached over HTTP or SSH. Any other host that doesn't accept the connection fails within 3s (unreachable: no answer within 3s, connection refused; is errand running there?, ssh could not connect to box). The table comes first, followed by one line for each peer that couldn't be read. A runner that accepted the connection but didn't answer in time is reported as timed out: connected, but the runner did not answer in time, so you can tell a slow runner from a missing one.

Reachability is now decided in the client transport, which every command uses, so peers, --where placement, run and attach get this too without changes of their own.

How: the HTTP transports dial through dialPeer (internal/client/reach.go). The connect step gets its own 3s budget, and the request after it keeps its full budget. If a connection to a Tailscale address (100.64.0.0/10 or fd7a:115c:a1e0::/48) is still pending after 300ms, dialPeer asks tailscaled once per process for the node's Online and LastSeen and cancels the dial when the node is offline. Healthy connections finish well before 300ms, so they never trigger the lookup. When Tailscale says the node is online, or anything about the lookup is unclear, the dial keeps its 3s budget. SSH peers get ConnectTimeout=3. If ssh has sent nothing after 300ms, errand runs ssh -G to find the address the ssh_config host points at and makes the same tailscaled check; for an offline node it stops ssh. ssh exiting with status 255 before the remote side sends anything is reported as unreachable. readFleet collects failures and prints them after rendering.

Tests: go test -race ./internal/client ./internal/tailnet ./cmd/errand pass, apart from TestChangeGCDryRunDoesNotWidenRestrictiveDownloadedStaging, which also fails on main when run as root in the container. New tests cover an offline node failing fast over TCP (IPv4 and IPv6) and over SSH, an online node getting its full budget, no tailscaled lookup for fast or non-tailnet connections, the caller's deadline being kept, a refused connection, ssh exit 255, ssh -G parsing, and failures printed after the table.

Note: this touches cmd/errand/main.go (readFleet) and internal/client/ssh.go (ssh args and connection), which #26 also changes. The overlap is small.

🤖 Generated with Claude Code

https://claude.ai/code/session_013E4B7TDRFcv2mAVSsCVnHn

A peer that cannot be connected to held every multi-peer command for the
request budget: the transport dialed with Go's 30s default and ps waited
its 15s control timeout. Reachability is now decided once, in the
transport, for every command:

- The connect step has its own 3s budget; the request after it keeps
  its full budget, so a slow runner is not mistaken for a missing one.
- A connection to a Tailscale address still pending after 300ms asks
  tailscaled whether the node is online; one reported offline fails at
  once with when it was last seen. Healthy connections never pay for it.
- SSH peers get ConnectTimeout=3, and ssh's exit 255 before the remote
  side spoke is reported as unreachable instead of EOF.

ps, df and workspaces print what reachable peers returned first, then
one line per peer that could not be read, saying whether it was
unreachable or connected but slow.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013E4B7TDRFcv2mAVSsCVnHn
@lydakis lydakis self-assigned this Oct 5, 2026

lydakis commented Oct 5, 2026

Copy link
Copy Markdown
Owner Author

github-advanced-security failed before it looked at the diff. The Copilot code-scanning agent got 402 You have exceeded your monthly quota when it tried to start its review session. This failure comes from the account's Copilot quota, not from this PR, and other PRs hit the same error. There's nothing to fix in this PR. Re-running it from here returns a 403, and it will keep failing until the quota resets.


Generated by Claude Code

@lydakis
lydakis marked this pull request as ready for review October 5, 2026 04:38
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-05T05:02:56.359148Z a90cb75 New commits
🔒 Security Review ✅ Completed 2026-10-05T05:02:44.187831Z a90cb75 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

An SSH peer on an offline Tailscale node still waited out ssh's 3s
ConnectTimeout. When ssh has sent nothing shortly after starting, look
up where the ssh_config host points with `ssh -G` and, if tailscaled
reports that node offline, stop ssh and report it as unreachable, the
same way TCP peers do.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013E4B7TDRFcv2mAVSsCVnHn
Comment thread internal/client/ssh.go Fixed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e4c60dbe63

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/client/reach.go Resolved
Tailscale's Online flag is control-plane state: a node that lost its
coordination server can still carry traffic, and over SSH the check ran
until the runner's first response byte, so a slow request to such a node
could be cut. A node now counts as gone only when it is offline and this
machine has had no WireGuard handshake with it within WireGuard's 3
minute session lifetime; a connection made a moment ago always leaves
one. The tailscaled status is shared for 2s instead of per process, so a
handshake made since is seen, and the background checks capture what
they use up front.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013E4B7TDRFcv2mAVSsCVnHn

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: aa949462a8

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/client/ssh.go Resolved
Comment thread internal/client/reach.go Resolved
Comment thread internal/client/reach.go Resolved
Review kept finding cases where the early offline verdict described
something other than the connection being attempted: a host with a
non-tailnet address too, an SSH host reached through a proxy, a status
captured before the attempt's own handshake. One rule now covers them:
an attempt is cut short only when every address its host resolves to
belongs to a node that is offline with no recent handshake, as observed
after the attempt began, and, for SSH, only when ssh connects directly.
Each attempt captures its lookups when it begins.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_013E4B7TDRFcv2mAVSsCVnHn
Comment thread internal/client/ssh.go Dismissed
@lydakis
lydakis merged commit 0ba13fb into main Oct 5, 2026
8 of 9 checks passed
@lydakis
lydakis deleted the claude/unreachable-peers-7euj2l branch October 5, 2026 05:09
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.

3 participants