Merge pull request #28052 from mavenugo/nid
Handle NetworkDettach for the case of network-id
This commit is contained in:
commit
7248742ae7
2 changed files with 35 additions and 1 deletions
|
@ -793,7 +793,10 @@ func (daemon *Daemon) disconnectFromNetwork(container *container.Container, n li
|
|||
|
||||
if daemon.clusterProvider != nil && n.Info().Dynamic() && !container.Managed {
|
||||
if err := daemon.clusterProvider.DetachNetwork(n.Name(), container.ID); err != nil {
|
||||
logrus.Warnf("error detaching from network %s: %v", n, err)
|
||||
logrus.Warnf("error detaching from network %s: %v", n.Name(), err)
|
||||
if err := daemon.clusterProvider.DetachNetwork(n.ID(), container.ID); err != nil {
|
||||
logrus.Warnf("error detaching from network %s: %v", n.ID(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -891,6 +894,9 @@ func (daemon *Daemon) releaseNetwork(container *container.Container) {
|
|||
if daemon.clusterProvider != nil && nw.Info().Dynamic() && !container.Managed {
|
||||
if err := daemon.clusterProvider.DetachNetwork(nw.Name(), container.ID); err != nil {
|
||||
logrus.Warnf("error detaching from network %s: %v", nw.Name(), err)
|
||||
if err := daemon.clusterProvider.DetachNetwork(nw.ID(), container.ID); err != nil {
|
||||
logrus.Warnf("error detaching from network %s: %v", nw.ID(), err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue