Fix Put without Get in overlay
| ... | ... |
@@ -318,6 +318,14 @@ func (d *Driver) Put(id string) error {
|
| 318 | 318 |
mount := d.active[id] |
| 319 | 319 |
if mount == nil {
|
| 320 | 320 |
logrus.Debugf("Put on a non-mounted device %s", id)
|
| 321 |
+ // but it might be still here |
|
| 322 |
+ if d.Exists(id) {
|
|
| 323 |
+ mergedDir := path.Join(d.dir(id), "merged") |
|
| 324 |
+ err := syscall.Unmount(mergedDir, 0) |
|
| 325 |
+ if err != nil {
|
|
| 326 |
+ logrus.Debugf("Failed to unmount %s overlay: %v", id, err)
|
|
| 327 |
+ } |
|
| 328 |
+ } |
|
| 321 | 329 |
return nil |
| 322 | 330 |
} |
| 323 | 331 |
|
| ... | ... |
@@ -1233,7 +1233,7 @@ func pingContainers(c *check.C, d *Daemon, expectFailure bool) {
|
| 1233 | 1233 |
runCommand(exec.Command(dockerBinary, args...)) |
| 1234 | 1234 |
} |
| 1235 | 1235 |
|
| 1236 |
-func (s *DockerDaemonSuite) TestDaemonRestartWithSockerAsVolume(c *check.C) {
|
|
| 1236 |
+func (s *DockerDaemonSuite) TestDaemonRestartWithSocketAsVolume(c *check.C) {
|
|
| 1237 | 1237 |
c.Assert(s.d.StartWithBusybox(), check.IsNil) |
| 1238 | 1238 |
|
| 1239 | 1239 |
socket := filepath.Join(s.d.folder, "docker.sock") |
| ... | ... |
@@ -1242,3 +1242,16 @@ func (s *DockerDaemonSuite) TestDaemonRestartWithSockerAsVolume(c *check.C) {
|
| 1242 | 1242 |
c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
| 1243 | 1243 |
c.Assert(s.d.Restart(), check.IsNil) |
| 1244 | 1244 |
} |
| 1245 |
+ |
|
| 1246 |
+func (s *DockerDaemonSuite) TestCleanupMountsAfterCrash(c *check.C) {
|
|
| 1247 |
+ c.Assert(s.d.StartWithBusybox(), check.IsNil) |
|
| 1248 |
+ |
|
| 1249 |
+ out, err := s.d.Cmd("run", "-d", "busybox", "top")
|
|
| 1250 |
+ c.Assert(err, check.IsNil, check.Commentf("Output: %s", out))
|
|
| 1251 |
+ id := strings.TrimSpace(out) |
|
| 1252 |
+ c.Assert(s.d.cmd.Process.Signal(os.Kill), check.IsNil) |
|
| 1253 |
+ c.Assert(s.d.Start(), check.IsNil) |
|
| 1254 |
+ mountOut, err := exec.Command("mount").CombinedOutput()
|
|
| 1255 |
+ c.Assert(err, check.IsNil, check.Commentf("Output: %s", mountOut))
|
|
| 1256 |
+ c.Assert(strings.Contains(string(mountOut), id), check.Equals, false, check.Commentf("Something mounted from older daemon start: %s", mountOut))
|
|
| 1257 |
+} |