Nested/side-by-side Nexus hangs on spawn: WORKERS_BRIDGE_SUBNET defaults collide #59
Labels
No labels
bug
duplicate
enhancement
help wanted
invalid
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lz/agent-nexus#59
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Symptom
Spawning a worker from a second Nexus instance that runs inside a Nexus worker (Docker-in-Docker) hangs indefinitely at "creating the container". The UI shows no error. Worse, the hang is accompanied by a loss of network connectivity from the worker container to the host Nexus —
notify-preview/notify-artifactstart timing out.Cause
WORKERS_BRIDGE_SUBNETdefaults to172.30.0.0/16(nexus/src/lib/server/config.ts), for every instance.A Nexus worker container is itself attached to the host Nexus's
nexus-workersbridge, so itseth0is on172.30.0.0/16and its default gateway is172.30.0.1— which is also how it reaches the host Nexus (NEXUS_URL=http://172.30.0.1:3001).When a Nexus running inside that worker calls
ensureWorkersBridge, it creates a bridge with the same default172.30.0.0/16. It is creating a network on top of its own gateway. The route to172.30.0.1is hijacked by the new bridge, the callback path dies, and the spawn wedges.Reproduced on the
feat/dockview-pr-abranch while standing up an isolated test instance in a DinD worker. Confirmed by:docker network inspect nexus-workersinside DinD →172.30.0.0/16/proc/net/routein the worker → default gw172.30.0.1viaeth0, network172.30.0.0/16curl http://172.30.0.1:3001/api/state→ timeout while the bridge existed; 200 immediately afterdocker network rm nexus-workersWorkaround: set
WORKERS_BRIDGE_SUBNET(and ideallyWORKERS_BRIDGE_NAME) to something non-colliding, e.g.172.28.0.0/16.Why it's worth fixing
Two things are wrong independently:
AGENTS.mdalready warns "pick a /16 that doesn't collide with existing docker networks" — but nothing enforces it, and the failure mode is an indefinite hang rather than an error. That's the expensive part: there is no signal pointing at the subnet.Suggested fix (smallest first)
Minimum: in
ensureWorkersBridge(nexus/src/lib/server/workers/workers-bridge.ts), before creating the bridge, check whether the requested subnet overlaps any network already visible to this Docker daemon or any address on the Nexus process's own interfaces. If it overlaps, throw a clear error naming the collision and pointing atWORKERS_BRIDGE_SUBNET. A loud failure beats a hang.Better: on collision, auto-pick the next free /16 from a candidate list (
172.30,172.28,172.27, …) and log which one was chosen.WORKERS_BRIDGE_SUBNETstays as the explicit override.Note the subnet is only consulted on first create — an existing network with the right name is reused as-is — so the check only needs to run on the create path.