Browse code

Fix daemon not cleaned up w/ live restore enabled

This patch makes sure daemon resources are cleaned up on shutdown if
there are no running containers.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>

Brian Goff authored on 2016/07/08 11:19:48
Showing 1 changed files
... ...
@@ -652,8 +652,12 @@ func (daemon *Daemon) Shutdown() error {
652 652
 	// Keep mounts and networking running on daemon shutdown if
653 653
 	// we are to keep containers running and restore them.
654 654
 	if daemon.configStore.LiveRestore {
655
-		return nil
655
+		// check if there are any running containers, if none we should do some cleanup
656
+		if ls, err := daemon.Containers(&types.ContainerListOptions{}); len(ls) != 0 || err != nil {
657
+			return nil
658
+		}
656 659
 	}
660
+
657 661
 	if daemon.containers != nil {
658 662
 		logrus.Debug("starting clean shutdown of all containers...")
659 663
 		daemon.containers.ApplyAll(func(c *container.Container) {