Skip to content

Commit

Permalink
When deleting an instance, avoid freakout if iscsi device is gone
Browse files Browse the repository at this point in the history
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 1079745 (Cherry picked for Essex)

Change-Id: Ib28790892eebe341ac10a92250cf872605fefe9b
  • Loading branch information
kk7ds authored and rmk40 committed Nov 17, 2012
1 parent 0edd3cb commit bd10241
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions nova/virt/libvirt/volume.py
Expand Up @@ -112,10 +112,11 @@ def _run_iscsiadm(self, iscsi_properties, iscsi_command, **kwargs):
(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):
Expand Down Expand Up @@ -201,7 +202,8 @@ def disconnect_volume(self, connection_info, mount_device):
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'),
Expand Down

0 comments on commit bd10241

Please sign in to comment.