mirror of
https://github.com/moby/moby.git
synced 2025-07-30 18:23:29 +03:00
Handle NetworkDettach for the case of network-id
When a container is attached to an "--attachable" network, it strictly forms the attacherKey using either the network-id or network-name because at the time of attachment, the daemon may not have the network downloaded locally from the manager. Hence, when the NetworkDettach is called, it should use either network-name or network-id. This fix addresses the missing network-id based dettachment case. Signed-off-by: Madhu Venugopal <madhu@docker.com>
This commit is contained in:
@ -295,6 +295,34 @@ func (s *DockerSwarmSuite) TestSwarmContainerEndpointOptions(c *check.C) {
|
||||
c.Assert(err, check.IsNil)
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmContainerAttachByNetworkId(c *check.C) {
|
||||
d := s.AddDaemon(c, true, true)
|
||||
|
||||
out, err := d.Cmd("network", "create", "--attachable", "-d", "overlay", "testnet")
|
||||
c.Assert(err, checker.IsNil)
|
||||
c.Assert(strings.TrimSpace(out), checker.Not(checker.Equals), "")
|
||||
networkID := strings.TrimSpace(out)
|
||||
|
||||
out, err = d.Cmd("run", "-d", "--net", networkID, "busybox", "top")
|
||||
c.Assert(err, checker.IsNil)
|
||||
cID := strings.TrimSpace(out)
|
||||
d.waitRun(cID)
|
||||
|
||||
_, err = d.Cmd("rm", "-f", cID)
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
out, err = d.Cmd("network", "rm", "testnet")
|
||||
c.Assert(err, checker.IsNil)
|
||||
|
||||
checkNetwork := func(*check.C) (interface{}, check.CommentInterface) {
|
||||
out, err := d.Cmd("network", "ls")
|
||||
c.Assert(err, checker.IsNil)
|
||||
return out, nil
|
||||
}
|
||||
|
||||
waitAndAssert(c, 3*time.Second, checkNetwork, checker.Not(checker.Contains), "testnet")
|
||||
}
|
||||
|
||||
func (s *DockerSwarmSuite) TestSwarmRemoveInternalNetwork(c *check.C) {
|
||||
d := s.AddDaemon(c, true, true)
|
||||
|
||||
|
Reference in New Issue
Block a user