Skip to content

fix(tailscale): guide recovery of existing foreground claims - #139283

Merged
steipete merged 2 commits into
mainfrom
fix/tailscale-orphan-prevention
Sep 5, 2026
Merged

steipete merged 2 commits into
mainfrom
fix/tailscale-orphan-prevention

Conversation

@steipete

@steipete steipete commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #126445 (Tailscale orphan crash loop), #126457, and #139261.

What Problem This Solves

Fixes an issue where a Gateway blocked by an existing foreground Tailscale claim recommends serve ... off, a command that only removes background Web handlers and cannot release that claim. Operators recovering an orphan left by a pre-fix Gateway need to identify and stop its confirmed owning process.

Why This Change Was Made

Foreground conflicts now identify the observed session and route and direct the operator to stop only a confirmed owning process. The already-read status snapshot supplies the diagnostic; Tailscale does not expose the claiming CLI PID, and this change does not infer process ownership. Existing background-route guidance remains scoped to a confirmed stale route.

The prevention repair landed in #139261 while this follow-up was in progress. This PR completes its named recovery-guidance follow-up and documents the one-time manual recovery. It also removes a fake-clock/filesystem-marker test handshake that stalled validation, retaining the real startup-timeout and original-error assertion.

User Impact

Operators can distinguish a foreground claim from a background handler and follow the appropriate recovery steps. Historical claims remain untouched until their owner confirms and stops them. See the Tailscale guide.

Thanks to @PollyBot13 for the original report and contribution in #126445 and #126457; the contributor trailer is preserved here and in #139261. No automatic orphan reclamation, shutdown-timeout policy, or persistence design is introduced.

Evidence

Exact head: 5d4fa89057e94ddbc4bf28b243856cd71eb14611. Exact-head CI is green. Fresh branch autoreview is scoped-clean at P0–P2. The final Crabbox five-file test run and full node scripts/check-changed.mjs completed successfully on this exact source.

  • The new Gateway foreground-conflict regression failed before the error change by receiving the ineffective background off command, and passed afterward with session/route/process-stop guidance. Existing background adoption and independent-route cases passed: 22 Gateway tests.
  • The five Tailscale owner/helper/Gateway/upgrade files passed 63 tests on Crabbox on the final head. Final-head local Gateway upgrade coverage passed 8 cases. Initial CI caught a default matcher type mismatch and unvalidated proxy interpolation; both are corrected and exact-head CI is green.
  • The readiness-timeout test previously stalled for 120 seconds while its fake clock awaited a filesystem marker. The simplified test exercises the real 15-second timeout and preserved diagnostic, with no timeout change or test-only production seam.
  • Local node scripts/check-changed.mjs passed initial guards, formatting, dependency/boundary checks, and the TypeScript graph boundary, then stopped because declaration inputs resolve outside this dependency-less worktree. Local process runs also encountered missing files in the shared tsx/zod installation. Prepared remote dependencies are used for complete proof.
  • Real authenticated Tailscale proof is unavailable locally: Tailscale 1.102.3 and tailscaled are installed, but read-only status reports BackendState=Stopped, SelfOnline=false. No operator daemon, route, Gateway, or state was changed. The approved fallback is process/socket and Gateway-owner tests. fix(tailscale): release managed routes after Gateway crashes #139261 separately records real built-Gateway before/after proof on Crabbox with a synthetic TCP claimant; it is not authenticated Tailscale proof.
  • Upstream Tailscale 1.102.3 source at 53a0d659afa51835dd7a9283873cca44261454f8: cmd/tailscale/cli/serve_v2.go:490-548,1529-1585 and ipn/ipnlocal/serve.go:425-433 establish foreground watch ownership and background-only handler removal.
  • Original fix(gateway): prevent Tailscale orphan crash loops on launchd restart #126457 ClawSweeper rank-up move about loaded-timeout policy/managed-update bootout: skipped because the approved prevention and this diagnostic follow-up do not implement that timeout policy.

Production LOC: +42/-13 (net +29). Tests/support: +12/-29 (net -17). Docs: +19/-1. Growth is the explicitly requested missing recovery path: port-scoped session/route extraction and carrying existing status into the error owner. The prevention in #139261 separately removed one production line. No new config/env option, schema, protocol, or external call.

NO-FOLLOW-UP: this completes the prevention PR's named recovery follow-up and removes the nearby fragile test handshake; no further owner refactor earns its scope here.

Final remote proof transcript

Provider blacksmith-testbox, lease tbx_01m1se3ea3ycw0epbexgc8hs58; backing workflow. The wrapper verified source 5d4fa89057e94ddbc4bf28b243856cd71eb14611, raw tree af21d3b07eb4252b45509e65260e8ccdd69ff548 before execution.

node scripts/run-vitest.mjs src/infra/tailscale-parent-loss.process.test.ts src/infra/tailscale-route-owner.worker.test.ts src/infra/tailscale.test.ts src/gateway/server-tailscale.test.ts src/gateway/server-tailscale-upgrade.test.ts
Gateway: 2 files, 22 tests passed
Infra: 3 files, 41 tests passed
PID SIGKILL -> claim released -> same-port replacement: passed
Process-group SIGKILL -> claim released -> same-port replacement: passed
Foreground conflict -> session/route/process-stop guidance, state unchanged: passed
Readiness timeout -> original diagnostic preserved: passed (15,018 ms)
node scripts/check-changed.mjs
Production and all core test typechecks: passed
Dead-export scans: 0 entries
Core/scripts lint, schema, database, loader, cycle, webhook and pairing guards: passed
Remote command exit=0; wrapper exit=0; runStatus=succeeded

The combined remote payload took 18m11s after source synchronization. The provider's external portal sync timed out after successful execution; this did not change the command/wrapper success. The lease was stopped after proof. Initial CI failures were corrected, then final exact-head CI passed. The latest ClawSweeper review had no findings or rank-up moves; fresh final branch autoreview was scoped-clean at P0–P2.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 5, 2026
@steipete
steipete marked this pull request as ready for review September 5, 2026 18:33
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 3:08 PM ET / 19:08 UTC.

ClawSweeper review

What this changes

The PR distinguishes foreground Tailscale conflicts in startup errors, documents recovery through the confirmed owning process, and simplifies the startup-timeout regression test.

Merge readiness

✅ Ready for maintainer review

This remains a useful recovery follow-up: current main and v2026.9.1 still recommend background-handler removal for foreground conflicts. No blocking patch defects found; the merged prevention repair does not replace this work.

Priority: P2
Reviewed head: 5d4fa89057e94ddbc4bf28b243856cd71eb14611

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, source-supported diagnostic repair with meaningful regression coverage and no blocking findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied MEMBER author classification exempts this PR from the external-contributor gate, and no authority change triggers additional proof. Fixture coverage exercises the changed Gateway conflict path; authenticated Tailscale recovery was explicitly unavailable and is not claimed as proven.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied MEMBER author classification exempts this PR from the external-contributor gate, and no authority change triggers additional proof. Fixture coverage exercises the changed Gateway conflict path; authenticated Tailscale recovery was explicitly unavailable and is not claimed as proven.
Evidence reviewed 10 items Current main still needs the diagnostic repair: The fetched main revision constructs the conflict error without status and always suggests removing a root handler; it cannot distinguish foreground sessions.
Latest supplied release retains the same guidance: The v2026.9.1 source also offers only the background root-handler removal command.
Production owner and dependency boundary: Gateway startup calls startGatewayTailscaleExposure, which calls claimTailscaleRoute. The patch carries its existing bounded Tailscale status snapshot into conflict formatting; subprocess ownership, route adoption, Serve/Funnel selection, and cleanup remain unchanged. This path depends on Tailscale CLI behavior, with no affirmative Codex dependency signal.
Findings None None.
Security None None.

How this fits together

Managed Tailscale ingress gives the Gateway an HTTPS endpoint through Serve or Funnel. Gateway startup reads existing routes, acquires a foreground claim, and reports conflicts through the route-ownership error.

flowchart TD
  A[Gateway startup] --> B[Read Tailscale routes]
  B --> C[Acquire foreground claim]
  C --> D{Port available?}
  D -->|Yes| E[Managed HTTPS endpoint]
  D -->|No| F[Classify existing claim]
  B --> F
  F --> G[Scoped recovery guidance]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +29, Tests -17, Docs +18. Total +30 across 7 files.

View PR surface stats
Area Files Added Removed Net
Source 2 42 13 +29
Tests 4 12 29 -17
Docs 1 19 1 +18
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 73 43 +30

Review metrics

Metric Value Why it matters
Production versus test growth Production net +29; tests/support net -17; docs net +18 Production growth is justified by the missing foreground recovery diagnostic, while the test cleanup removes a fragile synchronization handshake.

Technical review

Best possible solution:

Keep recovery classification in the existing error owner using the already-read status; the bounded production growth supplies missing session diagnostics without unsafe automatic process reclamation.

Do we have a high-confidence way to reproduce the issue?

Yes, from source: an existing foreground claim produces a port conflict, but current main recommends background-handler removal. The added Gateway regression covers that trigger; it was not executed during this review.

Is this the best way to solve the issue?

Yes. The existing conflict owner is the appropriate boundary, and reusing its caller’s status snapshot avoids extra subprocesses; automatic termination would require ownership evidence the snapshot cannot establish.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against e7590cd58042.

Labels

Label justifications:

  • P2: Corrects misleading recovery guidance for managed Tailscale conflicts without changing route acquisition or shutdown behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied MEMBER author classification exempts this PR from the external-contributor gate, and no authority change triggers additional proof. Fixture coverage exercises the changed Gateway conflict path; authenticated Tailscale recovery was explicitly unavailable and is not claimed as proven.

Evidence

What I checked:

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Jacqueline Henriksen: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-09-05T18:39:16.565Z sha e769a8b :: needs maintainer review before merge. :: none
  • reviewed 2026-09-05T18:48:43.936Z sha 5d4fa89 :: needs maintainer review before merge. :: none

@steipete
steipete merged commit 837e0b2 into main Sep 5, 2026
185 checks passed
@steipete
steipete deleted the fix/tailscale-orphan-prevention branch September 5, 2026 19:33
@steipete

steipete commented Sep 5, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 6, 2026
…w#139283)

* fix(tailscale): explain recovery for existing foreground claims

* fix(tailscale): validate diagnostic values and recovery matchers

Co-authored-by: PollyBot13 <[email protected]>

---------

Co-authored-by: PollyBot13 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs Improvements or additions to documentation gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant