diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-09-30 07:47:07 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-09-30 07:47:07 +0000 |
| commit | f6a0aaa5e823e6396ddda9b5d7f5863b08003e8d (patch) | |
| tree | 116c2be13de11a75aacd729c5d0d515e44274b9f | |
| parent | bcffec223be41576e40a3689718fbb87de759a08 (diff) | |
| parent | cc02f6a5604892fb776158dab06b06f24a25cbfb (diff) | |
| download | nova-f6a0aaa5e823e6396ddda9b5d7f5863b08003e8d.tar.gz nova-f6a0aaa5e823e6396ddda9b5d7f5863b08003e8d.tar.xz nova-f6a0aaa5e823e6396ddda9b5d7f5863b08003e8d.zip | |
Merge "libvirt: continue detach if instance not found"
| -rw-r--r-- | nova/virt/libvirt/driver.py | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/nova/virt/libvirt/driver.py b/nova/virt/libvirt/driver.py index 75a257a92..22c64a218 100644 --- a/nova/virt/libvirt/driver.py +++ b/nova/virt/libvirt/driver.py @@ -689,9 +689,6 @@ class LibvirtDriver(driver.ComputeDriver): def detach_volume(self, connection_info, instance_name, mountpoint): mount_device = mountpoint.rpartition("/")[2] try: - # NOTE(vish): This is called to cleanup volumes after live - # migration, so we should still logout even if - # the instance doesn't exist here anymore. virt_dom = self._lookup_by_name(instance_name) xml = self._get_disk_xml(virt_dom.XMLDesc(0), mount_device) if not xml: @@ -707,10 +704,20 @@ class LibvirtDriver(driver.ComputeDriver): else: flags = (libvirt.VIR_DOMAIN_AFFECT_CURRENT) virt_dom.detachDeviceFlags(xml, flags) - finally: - self.volume_driver_method('disconnect_volume', - connection_info, - mount_device) + except libvirt.libvirtError as ex: + # NOTE(vish): This is called to cleanup volumes after live + # migration, so we should still disconnect even if + # the instance doesn't exist here anymore. + error_code = ex.get_error_code() + if error_code == libvirt.VIR_ERR_NO_DOMAIN: + # NOTE(vish): + LOG.warn(_("During detach_volume, instance disappeared.")) + else: + raise + + self.volume_driver_method('disconnect_volume', + connection_info, + mount_device) @exception.wrap_exception() def _attach_lxc_volume(self, xml, virt_dom, instance_name): |
