summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVishvananda Ishaya <vishvananda@gmail.com>2012-09-27 20:38:59 +0000
committerVishvananda Ishaya <vishvananda@gmail.com>2012-09-27 22:57:23 +0000
commitcc02f6a5604892fb776158dab06b06f24a25cbfb (patch)
tree5a2489fcebc7c8943f2e459234085f2003d7992d
parent81fa6f717d6e32a4cfc2c734e228e60b204da045 (diff)
downloadnova-cc02f6a5604892fb776158dab06b06f24a25cbfb.tar.gz
nova-cc02f6a5604892fb776158dab06b06f24a25cbfb.tar.xz
nova-cc02f6a5604892fb776158dab06b06f24a25cbfb.zip
libvirt: continue detach if instance not found
Currently the libvirt code will always logout of the iscsi target during detach error, but the exception will cause the volume to remain in an attached state. This needs to be more consistent, so This patch checks specifically for not found and logs a warning and explicitly detaches. Any other exception will leave iscsi logged in and leave the volume in the attached state. Fixes bug 1057756 Change-Id: I23bb7f27e8a9b20fdbf62b0629ca8cc448f427c5
-rw-r--r--nova/virt/libvirt/driver.py21
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):