|
@@ -1441,13 +1441,19 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
|
|
out, err := d.Cmd("run", "-d", "busybox", "top")
|
|
out, err := d.Cmd("run", "-d", "busybox", "top")
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
id := strings.TrimSpace(out)
|
|
id := strings.TrimSpace(out)
|
|
- c.Assert(d.Signal(os.Kill), check.IsNil)
|
|
|
|
|
|
+
|
|
|
|
+ // If there are no mounts with container id visible from the host
|
|
|
|
+ // (as those are in container's own mount ns), there is nothing
|
|
|
|
+ // to check here and the test should be skipped.
|
|
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
|
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
|
|
+ if !strings.Contains(string(mountOut), id) {
|
|
|
|
+ d.Stop(c)
|
|
|
|
+ c.Skip("no container mounts visible in host ns")
|
|
|
|
+ }
|
|
|
|
|
|
- // container mounts should exist even after daemon has crashed.
|
|
|
|
- comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
|
|
|
|
- c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment)
|
|
|
|
|
|
+ // kill the daemon
|
|
|
|
+ c.Assert(d.Kill(), check.IsNil)
|
|
|
|
|
|
// kill the container
|
|
// kill the container
|
|
icmd.RunCommand(ctrBinary, "--address", "/var/run/docker/containerd/docker-containerd.sock",
|
|
icmd.RunCommand(ctrBinary, "--address", "/var/run/docker/containerd/docker-containerd.sock",
|
|
@@ -1459,7 +1465,7 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonAndContainerKill(c *chec
|
|
// Now, container mounts should be gone.
|
|
// Now, container mounts should be gone.
|
|
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
|
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
- comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
|
|
|
|
|
|
+ comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, d.Root, mountOut)
|
|
c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment)
|
|
c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment)
|
|
|
|
|
|
d.Stop(c)
|
|
d.Stop(c)
|
|
@@ -2047,13 +2053,18 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
id := strings.TrimSpace(out)
|
|
id := strings.TrimSpace(out)
|
|
|
|
|
|
- c.Assert(s.d.Signal(os.Kill), check.IsNil)
|
|
|
|
|
|
+ // kill the daemon
|
|
|
|
+ c.Assert(s.d.Kill(), check.IsNil)
|
|
|
|
+
|
|
|
|
+ // Check if there are mounts with container id visible from the host.
|
|
|
|
+ // If not, those mounts exist in container's own mount ns, and so
|
|
|
|
+ // the following check for mounts being cleared is pointless.
|
|
|
|
+ skipMountCheck := false
|
|
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
|
mountOut, err := ioutil.ReadFile("/proc/self/mountinfo")
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
-
|
|
|
|
- // container mounts should exist even after daemon has crashed.
|
|
|
|
- comment := check.Commentf("%s should stay mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
|
|
|
|
- c.Assert(strings.Contains(string(mountOut), id), check.Equals, true, comment)
|
|
|
|
|
|
+ if !strings.Contains(string(mountOut), id) {
|
|
|
|
+ skipMountCheck = true
|
|
|
|
+ }
|
|
|
|
|
|
// restart daemon.
|
|
// restart daemon.
|
|
s.d.Start(c, "--live-restore")
|
|
s.d.Start(c, "--live-restore")
|
|
@@ -2070,10 +2081,13 @@ func (s *DockerDaemonSuite) TestCleanupMountsAfterDaemonCrash(c *check.C) {
|
|
out, err = s.d.Cmd("stop", id)
|
|
out, err = s.d.Cmd("stop", id)
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
|
|
|
|
|
|
+ if skipMountCheck {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
// Now, container mounts should be gone.
|
|
// Now, container mounts should be gone.
|
|
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
|
mountOut, err = ioutil.ReadFile("/proc/self/mountinfo")
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
- comment = check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
|
|
|
|
|
|
+ comment := check.Commentf("%s is still mounted from older daemon start:\nDaemon root repository %s\n%s", id, s.d.Root, mountOut)
|
|
c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment)
|
|
c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, comment)
|
|
}
|
|
}
|
|
|
|
|