catalogue: give host-network containers the mesh's names too
A container with `network: host` was skipped when the mesh injects its
`<node>.internal` names, on the belief it "shares the machine's hosts file
already". It does not: `docker run --network host` still gives the container
its own /etc/hosts (localhost and its own id only), so every internal name the
mesh wrote is invisible inside it, and a client that dials one gets EAI_AGAIN.
This surfaced with the first host-network consumer to dial a provider by the
`.internal` address the mesh hands it as `${bound:...:at}` (the model-usage
store reaching its postgres). The remedy is the same `--add-host` every other
container already gets — the runtime accepts it with `--network host`
(verified against Docker) and mesh-host emits it for any network mode.
Claude-Session: https://claude.ai/code/session_01LrgweAeERJYBg88c5cKDzF
This commit is contained in:
@@ -73,18 +73,22 @@ func TestAContainersOwnNamesAreKept(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// A container on the machine's own network already shares its hosts file, and a runtime refuses
|
||||
// to write one for it — so adding names there fails the whole container for something it did not
|
||||
// need.
|
||||
func TestAContainerOnTheMachinesNetworkIsLeftAlone(t *testing.T) {
|
||||
// A container on the machine's own network gets the names too — it does NOT share the machine's
|
||||
// hosts file. `docker run --network host` still gives the container its own /etc/hosts (localhost
|
||||
// and its own id only), so every `<node>.internal` name the mesh wrote is invisible inside it, and a
|
||||
// client that dials one gets EAI_AGAIN. It gets the same `--add-host` entries every other container
|
||||
// gets (the runtime accepts them with `--network host`), so a host-network consumer can reach a
|
||||
// provider by the `.internal` address the mesh hands it.
|
||||
func TestAContainerOnTheMachinesNetworkIsGivenTheNamesToo(t *testing.T) {
|
||||
got := containersOf(t, Resolution{Node: "anchor", Modules: []Manifest{{
|
||||
Module: "control",
|
||||
Resources: []map[string]any{{"id": "c", "type": "container", "name": "c",
|
||||
"image": "registry.example/c@sha256:" + strings.Repeat("a", 64), "network": "host"}},
|
||||
}}}, Rendering{Names: map[string]string{"anchor.internal": "10.42.0.1"}})
|
||||
|
||||
if len(namesOf(got[0])) != 0 {
|
||||
t.Fatalf("a host-networked container was given names a runtime will refuse: %v", got[0])
|
||||
given := namesOf(got[0])
|
||||
if len(given) != 1 || given[0] != "anchor.internal:10.42.0.1" {
|
||||
t.Fatalf("a host-networked container was not given the mesh's names: %v", got[0])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user