fix(macos): name the gateway instead of addressing it, so bottles survive it moving #445
Reference in New Issue
Block a user
Delete Branch "fix/gateway-stable-hostname"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
closes #443.
Problem
The gateway's address is DHCP-assigned and moves whenever the infra container is recreated. Every agent-facing URL embedded it, and the proxy URL reaches the agent as process environment at
container exectime — which cannot be rewritten from outside once the agent is running. So a moved gateway stranded every running bottle permanently, recoverable only by relaunching and discarding the agent session.Seen live: infra moved
192.168.128.11 -> .19and three bottles that had been up for hours were left pointing at an address that no longer existed.Approach
Give the agent a stable name rather than an address.
GATEWAY_HOSTNAMEreplaces the IP in the egress proxy URL,NO_PROXY, git-http, and supervise URLs, and resolves through the bottle's own/etc/hosts.The key property:
environis immutable for a running process, but/etc/hostsis a file — it can be rewritten inside a container that is already running. That is what makes re-attachment possible at all.localhostand the container's own entry) and keeps the file's inode, so a pre-created/etc/hostsisn't replaced by a root-owned copy.Security note
The write goes through a new
exec_container_as_root. The agent runs asnodeand cannot rewrite/etc/hosts, so it cannot repoint its own gateway name; the host can. That asymmetry is deliberate and there's a test pinning it.Constraints found
Apple Container 1.0 has no container-name DNS on a user network (the only nameserver an agent sees is vmnet's, which doesn't know container names) and
container runhas no--add-host— both verified on the live host — so the entry is written by exec after start rather than declared at run.Not covered
The other half of #443:
Orchestrator._tokensis in-memory only, so per-bottle egress auth tokens are still lost across an orchestrator restart. A re-attached bottle resolves its policy but not its injected upstream credentials. Left deliberately, since fixing it touches the no-secrets-at-rest property.Tests
10 new (
test_macos_gateway_hosts.py) plus updates to the wiring tests that asserted address-based URLs. 1891 unit tests pass, pyright clean, pylint 9.82.Merge state
#442 has landed; this branch has been rebased onto
mainand is now a single independent commit. No ordering constraint remains.enumerate.CONTAINER_NAME_PREFIXis exported both here and in #440 — identical change, so whichever lands second may need a trivial conflict resolution.ae46779fe5to2f8539c2c7