From 2e41476a5fe58ceae7b3523e5e27718c2c7590e6 Mon Sep 17 00:00:00 2001 From: Albin Kerouanton Date: Wed, 12 Nov 2025 14:40:31 +0100 Subject: [PATCH] libnet: create DNS records on sbJoin (if not agent node) Commit a8b9eff90 removed a call to Network.updateSvcRecord from Network.createEndpoint on the grounds that: > all callers of Network.createEndpoint follow up with an Endpoint.Join, > which also sets up the DNS entry. However, the original call in Network.createEndpoint was gated by: ``` if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() { n.updateSvcRecord(context.WithoutCancel(ctx), ep, true) } ``` whereas the call in Endpoint.sbJoin() (invoked by Endpoint.Join()) is gated by: ``` if !n.getController().isAgent() { if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() { n.updateSvcRecord(context.WithoutCancel(ctx), ep, true) } } ``` As a result, once a node has joined a Swarm cluster, no DNS entries are created for non swarm-scoped networks. Change the condition used by `sbJoin` to match the original condition used in `createEndpoint`. Signed-off-by: Albin Kerouanton --- daemon/libnetwork/sandbox.go | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/daemon/libnetwork/sandbox.go b/daemon/libnetwork/sandbox.go index 4d0236f2e4..8f5e531188 100644 --- a/daemon/libnetwork/sandbox.go +++ b/daemon/libnetwork/sandbox.go @@ -348,10 +348,8 @@ func (sb *Sandbox) populateNetworkResources(ctx context.Context, ep *Endpoint) ( // Populate DNS records. n := ep.getNetwork() - if !n.getController().isAgent() { - if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() { - n.updateSvcRecord(context.WithoutCancel(ctx), ep, true) - } + if !n.getController().isSwarmNode() || n.Scope() != scope.Swarm || !n.driverIsMultihost() { + n.updateSvcRecord(context.WithoutCancel(ctx), ep, true) } if err := ep.addDriverInfoToCluster(); err != nil {