Skip to content

Commit

Permalink
Merge branch 'fix_exec_user_it' into 'IT-1.11.2'
Browse files Browse the repository at this point in the history
Allow containers to continue even if mount failed after live restore

虽然it这个版本不会用到该功能,但是还是合一下


See merge request docker/docker!199
  • Loading branch information
hqhq committed Dec 20, 2016
2 parents d8066c2 + 0fa01ce commit e52e5d4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
9 changes: 9 additions & 0 deletions daemon/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,15 @@ func (daemon *Daemon) restore() error {
continue
}
container.RWLayer = rwlayer
if err := daemon.Mount(container); err != nil {
// The mount is unlikely to fail. However, in case mount fails
// the container should be allowed to restore here. Some functionalities
// (like docker exec -u user) might be missing but container is able to be
// stopped/restarted/removed.
// See #29365 for related information.
// The error is only logged here.
logrus.Warnf("Failed to mount container %v: %v", id, err)
}
logrus.Debugf("Loaded container %v", container.ID)

containers[container.ID] = container
Expand Down
27 changes: 27 additions & 0 deletions integration-cli/docker_cli_daemon_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2159,3 +2159,30 @@ func (s *DockerSuite) TestDaemonDiscoveryBackendConfigReload(c *check.C) {
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster store: consul://consuladdr:consulport/some/path"))
c.Assert(out, checker.Contains, fmt.Sprintf("Cluster advertise: 192.168.56.100:0"))
}

// Test case for 29342
func (s *DockerDaemonSuite) TestExecWithUserAfterLiveRestore(c *check.C) {
testRequires(c, DaemonIsLinux)
err := s.d.StartWithBusybox("--live-restore")
c.Assert(err, checker.IsNil)

out, err := s.d.Cmd("run", "-d", "--name=top", "busybox", "sh", "-c", "addgroup -S test && adduser -S -G test test -D -s /bin/sh && top")
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))

waitRun("top")

out1, err := s.d.Cmd("exec", "-u", "test", "top", "id")
// uid=100(test) gid=101(test) groups=101(test)
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out1))

// restart daemon.
err = s.d.Restart("--live-restore")
c.Assert(err, checker.IsNil)

out2, err := s.d.Cmd("exec", "-u", "test", "top", "id")
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out2))
c.Assert(out1, check.Equals, out2, check.Commentf("Output: before restart '%s', after restart '%s'", out1, out2))

out, err = s.d.Cmd("stop", "top")
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
}

0 comments on commit e52e5d4

Please sign in to comment.