Repository navigation
fleet: tailnet tunnels use the seat's recorded tailnet proxy (#12555) - #12645
Conversation
A fleet client that finds no broker spawns `fleet proxy serve` with its own environment. From a sandbox shell that carries the platform egress proxy in HTTPS_PROXY, the broker then opens every tailnet tunnel through the wrong proxy and the queue and shell legs fail while it looks alive. Both spawn sites now set HTTPS_PROXY from fleet-proxy.env, the file the seat bootstrap writes beside tailscaled's node state ($FLEET_PROXY_ENV, then the named agent's state, then the legacy shared state). With no such file, as on a kernel-mode seat, the ambient env is kept. Refs #12555 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Warning Review limit reachedYou've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Next included review available in 30 minutes. View limit details
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. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: d4dd1f7229
ℹ️ 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".
| if let Some(proxy) = fleet_config::tailnet_https_proxy() { | ||
| cmd.env("HTTPS_PROXY", proxy); |
There was a problem hiding this comment.
Preserve the platform proxy for the Cloudflare leg
On a userspace seat with a persisted fleet-proxy.env, if tailscaled is stopped or restarting, this override also disables the independent Cloudflare fallback. In fleet-proxy/src/serve.rs, startup derives both the tailnet endpoint and cf_egress from HTTPS_PROXY (via egress_from_env and egress_from_env_url_port), so both transports now connect to the unavailable 127.0.0.1:3130 instead of letting Cloudflare use the caller's working platform egress proxy. The queue client's spawn path has the same issue. Preserve the ambient proxy separately for Cloudflare and apply the seat proxy only to tailnet connections.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Right, fixed in 8884e06. The spawn sites no longer override HTTPS_PROXY. Instead tunnel::egress_from_env (the tailnet egress, used by serve, stdio, dispatch and the laptop-agent legs) prefers the seat's fleet-proxy.env, while egress_from_env_url_port keeps the ambient proxy, so the Cloudflare leg still works when tailscaled is down. The bootstrap also removes a stale fleet-proxy.env when the seat comes up in kernel mode.
Generated by Claude Code
Overriding HTTPS_PROXY at broker spawn also moved the Cloudflare leg onto tailscaled's local proxy, so a stopped tailscaled took the fallback down with it. Read fleet-proxy.env where the tailnet egress is parsed instead: egress_from_env prefers the seat's recorded proxy and the Cloudflare leg keeps the ambient one. The spawn sites go back to inheriting the caller's env unchanged. The bootstrap now removes a fleet-proxy.env left from a userspace run when the seat comes up in kernel mode, since the file now steers tailnet tunnels directly. Refs #12555 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The broker parsed its tailnet egress once at startup. A broker auto-spawned while tailscaled was down (or before bootstrap wrote fleet-proxy.env) kept the ambient egress value — or none — for its whole life, so queue/shell tailnet tunnels kept failing after the tailnet recovered until a manual restart. That is the startup-cache half of the #12426 failure mode, left after the read-time preference landed for #12555 in #12645. Tunnel opens now resolve fresh via egress_from_env (recorded tailnet proxy first, ambient env second), falling back to the startup parse when fresh resolution fails. Opens are pooled and recovery-gated, so the re-read costs one small file read per new tunnel, not per request. The Cloudflare leg's egress is unchanged: the ambient platform proxy is its correct source. Oracle: the resolve_tailnet_egress preference — a fresh resolution wins, the startup parse is the fallback, and with neither the resolution error surfaces. Three unit tests cover the three branches; the fleet-proxy suite passes 113/113.
Refs #12555
Before: a fleet process started from a sandbox shell (for example a broker auto-spawned by
fleet agent doctor) inherited the platform egress proxy inHTTPS_PROXYand opened every tailnet tunnel through it. The queue and shell legs failed while the broker looked alive.After: tailnet tunnels use the seat's recorded tailnet proxy from
fleet-proxy.envwhenever that file exists, whatever the caller's environment. The Cloudflare leg keeps the ambient proxy, so it still works as a fallback when tailscaled is down. With no file, as on a kernel-mode seat, nothing changes.How:
fleet_config::tailnet_https_proxy()reads the first readable file among$FLEET_PROXY_ENV,~/.local/state/tailscale/agents/<slug>/fleet-proxy.env(the bootstrap's own slug rule over$FLEET_AGENT) and the legacy~/.local/state/tailscale/fleet-proxy.env.fleet_proxy::tunnel::egress_from_env, the one parser every tailnet leg uses, prefers it overHTTPS_PROXY. The muse bootstrap now removes a stalefleet-proxy.envwhen a seat comes up in kernel mode. Unit tests pin the lookup order, the slug rule and the parser; fleet-config and fleet-proxy tests pass and the fleet workspace builds with all features.Generated by Claude Code