From d2865f1e8a6bfc5d5e08ca9508ecba188b012f4d Mon Sep 17 00:00:00 2001 From: Albin Kerouanton Date: Thu, 23 Nov 2023 18:09:35 +0100 Subject: [PATCH] daemon: win: set DNS config on all adapters DNS config is a property of each adapter on Windows, thus we've a dedicated `EndpointOption` for that. The list of `EndpointOption` that should be applied to a given endpoint is built by `buildCreateEndpointOptions`. This function contains a seemingly flawed condition that adds the DNS config _iff_: 1. the network isn't internal ; 2. no ports are published / exposed through another sandbox endpoint ; While 1. does make sense, there's actually no justification for 2., hence this commit remove this part of the condition. This logic flaw has been made obvious by 0fd0e82, but it was originally introduced by d1e0a78. Commit and PR comments don't mention why this is done like so. Most probably, this was overlooked both by the original author and the PR reviewers. Signed-off-by: Albin Kerouanton --- daemon/network.go | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/daemon/network.go b/daemon/network.go index 897b898ad7..961c45ea96 100644 --- a/daemon/network.go +++ b/daemon/network.go @@ -871,14 +871,7 @@ func buildCreateEndpointOptions(c *container.Container, n *libnetwork.Network, e // On Windows, DNS config is a per-adapter config option whereas on Linux, it's a sandbox-wide parameter; hence why // we're dealing with DNS config both here and in buildSandboxOptions. Following DNS options are only honored by // Windows netdrivers, whereas DNS options in buildSandboxOptions are only honored by Linux netdrivers. - // - // Now that being said, you might ask: why is this cond checking whether there's already an endpoint with exposed / - // published ports tied to the container sandbox? Isn't that logic flawed? Well, probably it is! These DNS options - // were added by d1e0a78 at the end of buildCreateEndpointOptions. The fact that it was added *after* an - // early-return checking exposed / published ports was most probably overlooked by the original author and - // reviewers. - // TODO(aker): fix this ^ - if !n.Internal() && len(getPortMapInfo(sb)) == 0 { + if !n.Internal() { if len(c.HostConfig.DNS) > 0 { createOptions = append(createOptions, libnetwork.CreateOptionDNS(c.HostConfig.DNS)) } else if len(daemonDNS) > 0 {