Skip to content

engine: a nested engine on its parent's address range can resolve names again - #15099

Closed
sipsma wants to merge 2 commits into
mainfrom
sipsma/engine-network-overlap
Closed

sipsma wants to merge 2 commits into
mainfrom
sipsma/engine-network-overlap

Conversation

@sipsma

@sipsma sipsma commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

What this fixes

An engine whose container network overlaps a network it is attached to can't resolve any name. Every lookup times out after 30 s, so it can't pull images, load modules from git, or reach anything by hostname.

Who hits it today: any engine nested inside another engine on the same address range. The simplest case is the released engine image run with default flags inside a default engine: both take 10.87.0.0/16. With v1.0.0-beta.24, loading github.com/dagger/go from such a nested engine fails with:

Get "https://github.com/dagger/go/info/refs?service=git-upload-pack": dial tcp: lookup github.com: i/o timeout

The same failure broke the mock release publish check in #15080, two engines deep. There, an engine nested in the check's release engine was started on the release engine's own range.

Cause

The engine's bridge takes the first address of its range, and the engine points its own /etc/resolv.conf at that bridge address. The bridge also runs a dnsmasq that forwards to the original nameserver. When the range overlaps the network the engine sits on, the parent's DNS server (that network's first address) is the same address as the engine's own bridge. Lookups then go to the engine's own dnsmasq, which forwards them to itself, until they time out.

Fix

  • At start, the engine checks its configured --network-cidr against the subnets on its own interfaces, skipping loopback and its own bridge. If they overlap, it takes the next free range of the same size and logs a warning naming both. A range that doesn't overlap is used exactly as configured.
  • On a host install the bridge outlives the engine, and the chosen range can now differ between starts. The CNI bridge config therefore sets forceAddress, so the plugin replaces the bridge's old address instead of refusing to start. The subnet rules already replace their own stale rules when the range changes.
  • The bridge address is now the range's first address, as CNI's host-local IPAM assigns the gateway, for any prefix length. It used to be the range's base with its last byte set to 1, which was wrong for ranges not at a .0 base. The subnet rules' gateway uses the same function.

Testing

  • New integration test TestEngine/TestNestedOnParentNetwork: it nests an engine on its parent's range and pulls an image through it. On main it fails after about 65 s with lookup mirror.gcr.io: i/o timeout; with this change it passes. It runs in test-split/test-cli-engine.
  • Unit tests for the range selection and the bridge address (./network) and the CNI config (./network/netinst). They run in test-split/test-packages.
  • Reproduced in isolation as well: inside an engine on 10.91.0.0/16, a nested engine on 10.92.0.0/16 loads github.com/dagger/go in 2 s, while one on 10.91.0.0/16 fails with the error above after 30 s.

Cost: one listing of interface addresses at engine start.

@sipsma
sipsma force-pushed the sipsma/engine-network-overlap branch 3 times, most recently from a380a99 to 6af12e0 Compare November 10, 2026 22:10
An engine whose container network overlaps a subnet it is attached to cut
itself off from that subnet. Its bridge took the subnet's addresses,
among them the DNS server of an engine it runs inside on the same range,
so its lookups went to its own resolver, which forwarded them to itself,
and every lookup timed out after 30 s. A released engine image run with
default flags inside a default engine does this: both take 10.87.0.0/16,
and the nested engine can't resolve github.com or pull an image.

At start the engine now checks its network against the subnets on its
own interfaces, but its own bridge, and when they overlap takes the next
free range of the same size, saying so in its log.

Signed-off-by: Erik Sipsma <[email protected]>
…t address

An engine on a host install keeps its bridge across restarts, and its
range can now change between starts, but the CNI bridge plugin refuses a
bridge with another IPv4 address unless asked to replace it: the
engine's network config now asks it to.

The bridge's address, which is also the containers' DNS server, was the
range's base with its last byte set to 1, while CNI gives the gateway
the range's first address. For a range not at a .0 base, such as the one
after a /25, they differed: both the address and the subnet rules'
gateway are now the range's first address.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma

sipsma commented Nov 25, 2026

Copy link
Copy Markdown
Contributor Author

Everything this held is carried in #15273, which brings together the engine side of the remote cache: both commits are there with identical patches. Closing in favor of that pull request.

@sipsma sipsma closed this Nov 25, 2026
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