From 9c16f2a05245bc0a6ae0af5f8edbde65ba812837 Mon Sep 17 00:00:00 2001 From: "Daniel P. Berrange" Date: Thu, 5 Jul 2012 13:18:05 +0100 Subject: Don't let failure to delete filesystem block deletion of instances in libvirt During cleanup of instances, the libvirt driver tries to delete all files under the /var/lib/nova/instances/$INSTANCENAME directory. If Nova is running non-root, it is entirely possible for this to fail. If this happens an OSError is raised and the result is an unkillable instance. By catching and logging any OSError raised, we can ensure that the instances are cleaned up as much as possible and not left with unkillable instances. Change-Id: I204b087c610396d917e94a6e35dd2f5e1c26704e Signed-off-by: Daniel P. Berrange --- nova/virt/libvirt/driver.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'nova') diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 6a68f5cd7..28eb26bc8 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -551,7 +551,14 @@ class LibvirtDriver(driver.ComputeDriver): if FLAGS.libvirt_type == 'lxc': disk.destroy_container(self.container) if os.path.exists(target): - shutil.rmtree(target) + # If we fail to get rid of the directory + # tree, this shouldn't block deletion of + # the instance as whole. + try: + shutil.rmtree(target) + except OSError, e: + LOG.error(_("Failed to cleanup directory %(target)s: %(e)s") % + locals()) #NOTE(bfilippov): destroy all LVM disks for this instance self._cleanup_lvm(instance) -- cgit