1
0
mirror of https://github.com/moby/moby.git synced 2025-07-30 18:23:29 +03:00

Remove attachable network on swarm leave

- When the node leaves the cluster, if any user run
  container(s) is connected to the swarm network,
  then daemon needs to detach the container(s) and
  remove the network.

Signed-off-by: Alessandro Boch <aboch@docker.com>
This commit is contained in:
Alessandro Boch
2017-01-13 20:14:03 -08:00
parent ced293a015
commit 3cedca5d53
5 changed files with 75 additions and 5 deletions

View File

@ -358,6 +358,33 @@ func (s *DockerSwarmSuite) TestOverlayAttachable(c *check.C) {
c.Assert(strings.TrimSpace(out), checker.Equals, "true")
}
func (s *DockerSwarmSuite) TestOverlayAttachableOnSwarmLeave(c *check.C) {
d := s.AddDaemon(c, true, true)
// Create an attachable swarm network
nwName := "attovl"
out, err := d.Cmd("network", "create", "-d", "overlay", "--attachable", nwName)
c.Assert(err, checker.IsNil, check.Commentf(out))
// Connect a container to the network
out, err = d.Cmd("run", "-d", "--network", nwName, "--name", "c1", "busybox", "top")
c.Assert(err, checker.IsNil, check.Commentf(out))
// Leave the swarm
err = d.Leave(true)
c.Assert(err, checker.IsNil)
// Check the container is disconnected
out, err = d.Cmd("inspect", "c1", "--format", "{{.NetworkSettings.Networks."+nwName+"}}")
c.Assert(err, checker.IsNil)
c.Assert(strings.TrimSpace(out), checker.Equals, "<no value>")
// Check the network is gone
out, err = d.Cmd("network", "ls", "--format", "{{.Name}}")
c.Assert(err, checker.IsNil)
c.Assert(out, checker.Not(checker.Contains), nwName)
}
func (s *DockerSwarmSuite) TestSwarmRemoveInternalNetwork(c *check.C) {
d := s.AddDaemon(c, true, true)