Skip to content

Commit 19dc4af

Browse files
committed
bugfix: delete the JoinOptionPriority for connect panic
It seems a bug of libnetwork. When libnetwork restores the sandbox, it forgets to initialize the epPriority map. So the Join panic. To void the problem, we disable Priority join option. Indeed the moby does not use the join option Signed-off-by: Eric Li <[email protected]>
1 parent 196943d commit 19dc4af

File tree

2 files changed

+82
-2
lines changed

2 files changed

+82
-2
lines changed

test/cli_network_test.go

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,3 +445,82 @@ func (suite *PouchNetworkSuite) TestNetworkDisconnect(c *check.C) {
445445
command.PouchRun("stop", "-t", "1", name).Assert(c, icmd.Success)
446446
command.PouchRun("start", name).Assert(c, icmd.Success)
447447
}
448+
449+
// TestNetworkConnectWithRestart is to verify the 'network connect'
450+
// and 'network disconnect' after restart daemon.
451+
func (suite *PouchNetworkSuite) TestNetworkConnectWithRestart(c *check.C) {
452+
// start the test pouch daemon
453+
dcfg, err := StartDefaultDaemonDebug()
454+
if err != nil {
455+
c.Skip("daemon start failed.")
456+
}
457+
defer dcfg.KillDaemon()
458+
459+
// pull image
460+
RunWithSpecifiedDaemon(dcfg, "pull", busyboxImage).Assert(c, icmd.Success)
461+
462+
bridgeName := "p1"
463+
networkName := "net1"
464+
containerName := "TestNetworkConnectWithRestart"
465+
466+
// create bridge device
467+
br, err := createBridge("p1")
468+
c.Assert(err, check.Equals, nil)
469+
defer netlink.LinkDel(br)
470+
471+
// create bridge network
472+
RunWithSpecifiedDaemon(dcfg, "network", "create",
473+
"-d", "bridge",
474+
"--subnet=172.18.0.0/24", "--gateway=172.18.0.1",
475+
"-o", "com.docker.network.bridge.name="+bridgeName, networkName).Assert(c, icmd.Success)
476+
defer func() {
477+
RunWithSpecifiedDaemon(dcfg, "network", "rm", networkName).Assert(c, icmd.Success)
478+
}()
479+
480+
// create container
481+
RunWithSpecifiedDaemon(dcfg, "run", "-d", "--name", containerName, busyboxImage, "top").Assert(c, icmd.Success)
482+
defer func() {
483+
RunWithSpecifiedDaemon(dcfg, "rm", "-f", containerName).Assert(c, icmd.Success)
484+
}()
485+
486+
// restart daemon
487+
err = RestartDaemon(dcfg)
488+
c.Assert(err, check.IsNil)
489+
490+
// connect a network
491+
RunWithSpecifiedDaemon(dcfg, "network", "connect", networkName, containerName).Assert(c, icmd.Success)
492+
493+
// inspect container check result
494+
ret := RunWithSpecifiedDaemon(dcfg, "inspect", containerName).Assert(c, icmd.Success)
495+
496+
out := ret.Stdout()
497+
found := false
498+
for _, line := range strings.Split(out, "\n") {
499+
if strings.Contains(line, "net1") {
500+
found = true
501+
break
502+
}
503+
}
504+
c.Assert(found, check.Equals, true)
505+
506+
// restart daemon
507+
err = RestartDaemon(dcfg)
508+
c.Assert(err, check.IsNil)
509+
510+
// disconnect a network
511+
RunWithSpecifiedDaemon(dcfg, "network", "disconnect", networkName, containerName).Assert(c, icmd.Success)
512+
513+
// inspect container check result
514+
ret = RunWithSpecifiedDaemon(dcfg, "inspect", containerName).Assert(c, icmd.Success)
515+
516+
out = ret.Stdout()
517+
found = false
518+
for _, line := range strings.Split(out, "\n") {
519+
if strings.Contains(line, "net1") {
520+
found = true
521+
break
522+
}
523+
}
524+
525+
c.Assert(found, check.Equals, false)
526+
}

vendor/github.com/docker/libnetwork/sandbox_store.go

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)