diff options
| author | Daniel P. Berrange <berrange@redhat.com> | 2012-07-05 13:18:05 +0100 |
|---|---|---|
| committer | Daniel P. Berrange <berrange@redhat.com> | 2012-07-19 12:20:23 +0100 |
| commit | 9c16f2a05245bc0a6ae0af5f8edbde65ba812837 (patch) | |
| tree | b9df79873b3f392cc122a5081ac54af2772d0713 | |
| parent | 5f45eadbf2c1ea4a4cf6c9358aac269ca3f2cff6 (diff) | |
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 <berrange@redhat.com>
| -rw-r--r-- | nova/virt/libvirt/driver.py | 9 |
1 files changed, 8 insertions, 1 deletions
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) |
