The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/1964
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === removeUnixDevices() and removeDiskDevices() both abort after the first failure. We need to check for errors in cleanup to avoid running rm -rf * on any remaining devices. We were hit by this after a stale nfs mount failed to umount properly, which led to another attached disk device being wiped. I also reported bug 1576082 to launchpad.
From 2aa4e1057c0a0560bbbc779677edd71f3dfb30d2 Mon Sep 17 00:00:00 2001 From: David Hedberg <david.hedb...@gmail.com> Date: Thu, 28 Apr 2016 11:29:41 +0200 Subject: [PATCH] Check for errors when removing devices during cleanup removeUnixDevices() and removeDiskDevices() both abort after the first failure. We need to check for errors in cleanup to avoid running rm -rf * on any remaining devices. --- lxd/container_lxc.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/lxd/container_lxc.go b/lxd/container_lxc.go index 70f483f..58a60e5 100644 --- a/lxd/container_lxc.go +++ b/lxd/container_lxc.go @@ -1763,10 +1763,14 @@ func (c *containerLXC) Restore(sourceContainer container) error { return nil } -func (c *containerLXC) cleanup() { +func (c *containerLXC) cleanup() error { // Unmount any leftovers - c.removeUnixDevices() - c.removeDiskDevices() + if err := c.removeUnixDevices(); err != nil { + return err + } + if err := c.removeDiskDevices(); err != nil { + return err + } // Remove the security profiles AADeleteProfile(c) @@ -1777,6 +1781,8 @@ func (c *containerLXC) cleanup() { // Remove the shmounts path os.RemoveAll(shared.VarPath("shmounts", c.Name())) + + return nil } func (c *containerLXC) Delete() error { @@ -1792,7 +1798,9 @@ func (c *containerLXC) Delete() error { } // Clean things up - c.cleanup() + if err := c.cleanup(); err != nil { + return err + } // Delete the container from disk if shared.PathExists(c.Path()) { @@ -1823,7 +1831,9 @@ func (c *containerLXC) Rename(newName string) error { } // Clean things up - c.cleanup() + if err := c.cleanup(); err != nil { + return err + } // Rename the logging path os.RemoveAll(shared.LogPath(newName))
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel