mirror of
https://github.com/moby/moby.git
synced 2026-01-11 18:51:37 +00:00
Merge pull request #51495 from akerouanton/revert-a8b9eff90
libnet: create DNS records on sbJoin (if not agent node)
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user