libnet: populateNetworkResourcesOS: updateDNS only if !needResolver

When ep.needResolver() is true, sb.startResolver() calls sb.rebuildDNS()
which doesn't update the resolv.conf hash file.

Subsequent calls to sb.updateDNS() (which is only called by
populateNetworkResourcesOS) won't have any effect since it'll compare
the hash file and consider that the file was manually modified.

Make this explicit by gating the call to updateDNS() on !needResolver().

Signed-off-by: Albin Kerouanton <albin.kerouanton@docker.com>
This commit is contained in:
Albin Kerouanton
2025-11-25 11:26:05 +01:00
parent 6e52828ec3
commit 937246a868

View File

@@ -366,6 +366,11 @@ func (sb *Sandbox) populateNetworkResourcesOS(ctx context.Context, ep *Endpoint)
if ep.needResolver() {
sb.startResolver(false)
} else {
// Make sure /etc/resolv.conf is set up.
if err := sb.updateDNS(ep.getNetwork().enableIPv6); err != nil {
return err
}
}
if i != nil && i.srcName != "" {
@@ -448,10 +453,6 @@ func (sb *Sandbox) populateNetworkResourcesOS(ctx context.Context, ep *Endpoint)
}
sb.addHostsEntries(ctx, ep.getEtcHostsAddrs())
// Make sure /etc/resolv.conf is set up.
if err := sb.updateDNS(ep.getNetwork().enableIPv6); err != nil {
return err
}
// Populate load balancer only after updating all the other
// information including gateway and other routes so that