Merge pull request #51495 from akerouanton/revert-a8b9eff90

libnet: create DNS records on sbJoin (if not agent node)
This commit is contained in:
Albin Kerouanton
2025-11-13 20:02:28 +01:00
committed by GitHub
2 changed files with 29 additions and 5 deletions

View File

@@ -1092,7 +1092,7 @@ func TestDisableIPv6OnInterface(t *testing.T) {
// There should not be an IPv6 DNS or /etc/hosts entry.
runRes := container.RunAttach(ctx, t, c,
container.WithNetworkMode(tc.netName),
container.WithCmd("ping", "-6", ctrName),
container.WithCmd("ping", "-6", "-c1", ctrName),
)
assert.Check(t, is.Equal(runRes.ExitCode, 1))
assert.Check(t, is.Contains(runRes.Stderr.String(), "bad address"))
@@ -2032,3 +2032,29 @@ func TestLegacyLinksEnvVars(t *testing.T) {
})
}
}
// TestDNSNamesForNonSwarmScopedNetworks checks that container names can be resolved for non-swarm-scoped networks once
// a node has joined a Swarm cluster.
//
// Regression test for https://github.com/moby/moby/issues/51491.
func TestDNSNamesForNonSwarmScopedNetworks(t *testing.T) {
ctx := setupTest(t)
d := daemon.New(t)
d.StartAndSwarmInit(ctx, t)
defer d.Stop(t)
c := d.NewClientT(t)
defer c.Close()
const bridgeName = "dnsnames-with-swarm"
network.CreateNoError(ctx, t, c, bridgeName)
defer network.RemoveNoError(ctx, t, c, bridgeName)
res := container.RunAttach(ctx, t, c,
container.WithName("test"),
container.WithCmd("nslookup", "-type=a", "test."),
container.WithNetworkMode(bridgeName),
container.WithAutoRemove)
assert.Equal(t, res.ExitCode, 0, "exit code: %d, expected 0; stdout:\n%s", res.ExitCode, res.Stdout)
}