Don't set up DNS in Network.createEndpoint

DNS is set up when the endpoint is joined to a network.

It was added in commit 4850c5f (Avoid duplicate entries in
/etc/hosts) then simplified in bcca214 (libnetwork: open-code
updating svc records) and seems to be related to setting up a
name on a swarm node that isn't running the container with the
endpoint.

But, all callers of Network.createEndpoint follow up with an
Endpoint.Join, which also sets up the DNS entry. Those callers are:
  Network.createLoadBalancerSandbox
  Network.CreateEndpoint
    - called by Daemon.connectToNetwork
    - called by Sandbox.setupDefaultGateway
    - called by builder-net/executor.go: iface.init

None of them bail out before the Join for a Swarm case.

So, it looks like enough has changed that the createEndpoint code is
no longer needed (it predates the internal DNS server) ... remove it.

Signed-off-by: Rob Murray <rob.murray@docker.com>
This commit is contained in:
Rob Murray
2025-01-15 18:03:41 +00:00
parent ddf10ee1cd
commit a8b9eff902

View File

@@ -1268,15 +1268,6 @@ func (n *Network) createEndpoint(ctx context.Context, name string, options ...En
}
}()
if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() {
n.updateSvcRecord(context.WithoutCancel(ctx), ep, true)
defer func() {
if err != nil {
n.updateSvcRecord(context.WithoutCancel(ctx), ep, false)
}
}()
}
return ep, nil
}