Skip to content

fix(fleet): recorded tailnet proxy beats ambient env in the Python client and broker - #13071

Merged
dezren39 merged 1 commit into
mainfrom
lane-ld-12426
Nov 23, 2026
Merged

dezren39 merged 1 commit into
mainfrom
lane-ld-12426

Conversation

@dezren39

@dezren39 dezren39 commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

For #12426 — the Python-side remainder of the #12555 failure class (auto-spawned broker inherits the caller's ambient proxy env and silently breaks tailnet tunnels).

What

The Rust broker learned the durable rule in #12645: fleet_config::tailnet_https_proxy() resolves the seat's recorded fleet-proxy.env ahead of the ambient HTTPS_PROXY for tailnet tunnels. The Python paths still read only the ambient env:

  • tunnel_socket in pkgs/fleet/laptop-agent.py
  • broker_tunnel_socket in pkgs/fleet/laptop-agent-broker.py

so a Python client/broker (re)started from a sandbox shell still inherited the platform egress proxy and broke the queue/shell legs exactly as filed in #12426 — while the bootstrap's own comment ("Fleet's tailnet tunnels prefer this file over the ambient proxy") claimed otherwise.

This PR mirrors the rule in Python:

  • laptop-agent.py gains tailnet_https_proxy() with fleet-config's exact candidate order ($FLEET_PROXY_ENV, then the named agent's ~/.local/state/tailscale/agents/<slug>/fleet-proxy.env, then ~/.local/state/tailscale/fleet-proxy.env), bootstrap slug rule, and env-file parse rule; tunnel_socket prefers the recorded proxy for the tailnet leg.
  • The Cloudflare leg keeps the ambient proxy, as in the Rust shape.
  • The broker resolves through the client's resolver when the deployed copy provides one (older copies leave the ambient env in charge).
  • A kernel-mode seat has no file (the bootstrap removes it), so nothing changes there.

Verification

New pkgs/fleet/tests/test_tailnet_proxy_env.py — 9 tests, all passing (python3 -m unittest discover -s pkgs/fleet/tests): the slug/candidate/parse cases mirror fleet-config's Rust cases value-for-value; resolution-order tests cover shared < agent < explicit; an end-to-end tunnel_socket test against a fake CONNECT proxy proves the recorded proxy wins over an ambient egress proxy and the ambient proxy is used when no file exists. Both edited files compile clean (py_compile).

Scope note

#12426 stays open: the out-of-repo spawn sites it names (the sandbox ensure layer) now have nothing left to police for correctness — both broker implementations self-correct at CONNECT time — but retiring or re-pointing that watchdog is a primary-seat call, and #12555 remains the parent record of the failure class.


See it in action
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

…ient and broker

For #12426 (the Python-side remainder of the #12555 failure class).

The Rust broker learned this rule in #12645: fleet-config's
tailnet_https_proxy resolves the seat's recorded fleet-proxy.env
ahead of the ambient HTTPS_PROXY for tailnet tunnels. The Python
paths still read only the ambient env, so a Python client or broker
(re)started from a sandbox shell inherited the platform egress proxy
and every tailnet CONNECT failed while the process looked alive.

laptop-agent.py gains the mirror resolver — candidate order
($FLEET_PROXY_ENV, then the named agent's
~/.local/state/tailscale/agents/<slug>/fleet-proxy.env, then
~/.local/state/tailscale/fleet-proxy.env), the bootstrap slug rule,
and the env-file parse rule all match fleet-config's — and
tunnel_socket prefers it for the tailnet leg. The Cloudflare leg
keeps the ambient proxy, as in the Rust shape. The broker's
broker_tunnel_socket resolves through the client's resolver when
the deployed copy provides one.

Tests: pkgs/fleet/tests/test_tailnet_proxy_env.py, 9 cases mirroring
fleet-config's slug/candidate/parse cases plus resolution order and
an end-to-end tunnel_socket preference check against a fake CONNECT
proxy. Run: python3 -m unittest discover -s pkgs/fleet/tests — OK.
@coderabbitai

coderabbitai Bot commented Nov 23, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You'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 4 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd618964-23f4-48c8-ba6c-33dcfd38e8d1
Commits

Reviewing files that changed from the base of the PR and between a7794b9 and cd3077f.

Files selected for processing: 3

  • pkgs/fleet/laptop-agent-broker.py
  • pkgs/fleet/laptop-agent.py
  • pkgs/fleet/tests/test_tailnet_proxy_env.py
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 23, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-23T07:52:02.130779Z cd3077f PR opened
ℹ️ 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.

@dezren39
dezren39 merged commit 382dc9b into main Nov 23, 2026
2 checks passed
@dezren39
dezren39 deleted the lane-ld-12426 branch November 23, 2026 07:51
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.

1 participant