From ab7e4f2817d8201cd2364cf09aa01f505e911183 Mon Sep 17 00:00:00 2001 From: Dan Smith Date: Mon, 9 Jul 2012 13:37:01 -0700 Subject: When deleting an instance, avoid freakout if iscsi device is gone It's fairly easy to get into a state where an instance is not running, the iscsi infrastructure has been torn down, and the instance cannot be deleted because the iscsi device cannot be successfully removed. This patch ignores the associated return value for that scenario and marches forward in the teardown process. Fixes bug 1022520 Change-Id: Ib28790892eebe341ac10a92250cf872605fefe9b --- nova/virt/libvirt/volume.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'nova') diff --git a/nova/virt/libvirt/volume.py b/nova/virt/libvirt/volume.py index dfba9325c..f5a346ca7 100644 --- a/nova/virt/libvirt/volume.py +++ b/nova/virt/libvirt/volume.py @@ -108,10 +108,11 @@ class LibvirtISCSIVolumeDriver(LibvirtVolumeDriver): (iscsi_command, out, err)) return (out, err) - def _iscsiadm_update(self, iscsi_properties, property_key, property_value): + def _iscsiadm_update(self, iscsi_properties, property_key, property_value, + **kwargs): iscsi_command = ('--op', 'update', '-n', property_key, '-v', property_value) - return self._run_iscsiadm(iscsi_properties, iscsi_command) + return self._run_iscsiadm(iscsi_properties, iscsi_command, **kwargs) @utils.synchronized('connect_volume') def connect_volume(self, connection_info, mount_device): @@ -197,7 +198,8 @@ class LibvirtISCSIVolumeDriver(LibvirtVolumeDriver): devices = self.connection.get_all_block_devices() devices = [dev for dev in devices if dev.startswith(device_prefix)] if not devices: - self._iscsiadm_update(iscsi_properties, "node.startup", "manual") + self._iscsiadm_update(iscsi_properties, "node.startup", "manual", + check_exit_code=[0, 255]) self._run_iscsiadm(iscsi_properties, ("--logout",), check_exit_code=[0, 255]) self._run_iscsiadm(iscsi_properties, ('--op', 'delete'), -- cgit