Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

Commit bca9415

Browse files
committed
Merge pull request #19356 from sanimej/restart
Vendoring libnetwork v0.5.6
2 parents 8ce8813 + 7481961 commit bca9415

File tree

5 files changed

+65
-6
lines changed

5 files changed

+65
-6
lines changed

hack/vendor.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ clone git github.com/RackSec/srslog 6eb773f331e46fbba8eecb8e794e635e75fc04de
2727
clone git github.com/imdario/mergo 0.2.1
2828

2929
#get libnetwork packages
30-
clone git github.com/docker/libnetwork v0.5.5
30+
clone git github.com/docker/libnetwork v0.5.6
3131
clone git github.com/armon/go-metrics eb0af217e5e9747e41dd5303755356b62d28e3ec
3232
clone git github.com/hashicorp/go-msgpack 71c2886f5a673a35f909803f38ece5810165097b
3333
clone git github.com/hashicorp/memberlist 9a1e242e454d2443df330bdd51a436d5a9058fc4

integration-cli/docker_cli_restart_test.go

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,46 @@ func (s *DockerSuite) TestContainerRestartSuccess(c *check.C) {
153153
err = waitInspect(id, "{{.State.Status}}", "running", 5*time.Second)
154154
c.Assert(err, check.IsNil)
155155
}
156+
157+
func (s *DockerSuite) TestUserDefinedNetworkWithRestartPolicy(c *check.C) {
158+
testRequires(c, DaemonIsLinux, SameHostDaemon, NotUserNamespace)
159+
dockerCmd(c, "network", "create", "-d", "bridge", "udNet")
160+
161+
dockerCmd(c, "run", "-d", "--net=udNet", "--name=first", "busybox", "top")
162+
c.Assert(waitRun("first"), check.IsNil)
163+
164+
dockerCmd(c, "run", "-d", "--restart=always", "--net=udNet", "--name=second",
165+
"--link=first:foo", "busybox", "top")
166+
c.Assert(waitRun("second"), check.IsNil)
167+
168+
// ping to first and its alias foo must succeed
169+
_, _, err := dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
170+
c.Assert(err, check.IsNil)
171+
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "foo")
172+
c.Assert(err, check.IsNil)
173+
174+
// Now kill the second container and let the restart policy kick in
175+
pidStr, err := inspectField("second", "State.Pid")
176+
c.Assert(err, check.IsNil)
177+
178+
pid, err := strconv.Atoi(pidStr)
179+
c.Assert(err, check.IsNil)
180+
181+
p, err := os.FindProcess(pid)
182+
c.Assert(err, check.IsNil)
183+
c.Assert(p, check.NotNil)
184+
185+
err = p.Kill()
186+
c.Assert(err, check.IsNil)
187+
188+
err = waitInspect("second", "{{.RestartCount}}", "1", 5*time.Second)
189+
c.Assert(err, check.IsNil)
190+
191+
err = waitInspect("second", "{{.State.Status}}", "running", 5*time.Second)
192+
193+
// ping to first and its alias foo must still succeed
194+
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "first")
195+
c.Assert(err, check.IsNil)
196+
_, _, err = dockerCmdWithError("exec", "second", "ping", "-c", "1", "foo")
197+
c.Assert(err, check.IsNil)
198+
}

vendor/src/github.com/docker/libnetwork/CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# Changelog
22

3+
## 0.5.6 (2016-01-14)
4+
- Setup embedded DNS server correctly on container restart. Fixes docker/docker#19354
5+
36
## 0.5.5 (2016-01-14)
47
- Allow network-scoped alias to be resolved for anonymous endpoint
58
- Self repair corrupted IP database that could happen in 1.9.0 & 1.9.1

vendor/src/github.com/docker/libnetwork/resolver.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ import (
1515
type Resolver interface {
1616
// Start starts the name server for the container
1717
Start() error
18-
// Stop stops the name server for the container
18+
// Stop stops the name server for the container. Stopped resolver
19+
// can be reused after running the SetupFunc again.
1920
Stop()
2021
// SetupFunc() provides the setup function that should be run
2122
// in the container's network namespace.
@@ -102,6 +103,8 @@ func (r *resolver) Stop() {
102103
if r.server != nil {
103104
r.server.Shutdown()
104105
}
106+
r.conn = nil
107+
r.err = fmt.Errorf("setup not done yet")
105108
}
106109

107110
func (r *resolver) SetExtServers(dns []string) {

vendor/src/github.com/docker/libnetwork/sandbox.go

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -488,23 +488,22 @@ func (sb *sandbox) resolveName(req string, networkName string, epList []*endpoin
488488
}
489489

490490
func (sb *sandbox) SetKey(basePath string) error {
491-
var err error
492491
if basePath == "" {
493492
return types.BadRequestErrorf("invalid sandbox key")
494493
}
495494

496495
sb.Lock()
497-
osSbox := sb.osSbox
496+
oldosSbox := sb.osSbox
498497
sb.Unlock()
499498

500-
if osSbox != nil {
499+
if oldosSbox != nil {
501500
// If we already have an OS sandbox, release the network resources from that
502501
// and destroy the OS snab. We are moving into a new home further down. Note that none
503502
// of the network resources gets destroyed during the move.
504503
sb.releaseOSSbox()
505504
}
506505

507-
osSbox, err = osl.GetSandboxForExternalKey(basePath, sb.Key())
506+
osSbox, err := osl.GetSandboxForExternalKey(basePath, sb.Key())
508507
if err != nil {
509508
return err
510509
}
@@ -520,6 +519,17 @@ func (sb *sandbox) SetKey(basePath string) error {
520519
}
521520
}()
522521

522+
// If the resolver was setup before stop it and set it up in the
523+
// new osl sandbox.
524+
if oldosSbox != nil && sb.resolver != nil {
525+
sb.resolver.Stop()
526+
527+
sb.osSbox.InvokeFunc(sb.resolver.SetupFunc())
528+
if err := sb.resolver.Start(); err != nil {
529+
log.Errorf("Resolver Setup/Start failed for container %s, %q", sb.ContainerID(), err)
530+
}
531+
}
532+
523533
for _, ep := range sb.getConnectedEndpoints() {
524534
if err = sb.populateNetworkResources(ep); err != nil {
525535
return err

0 commit comments

Comments
 (0)