Always call hdisk removal from vscsi volume driver
This change updates the vscsi volume driver to ensure that the hdisk removal is always invoked. The hdisk removal significantly speeds up subsequent discoveries. The changes to pypowervm should remove risks from running the API. The change is done so that an error from the hdisk job does not block volume disconnect. The volume will have already been disconnected from the VM by the time the command is run. If the hdisk remove fails for some reason, a subsequent attach should clean it up (but can be slower when it does so). Change-Id: Ib823f793ec4b951111301286743c6bd243b863fe
This commit is contained in:
parent
9916adf375
commit
e7090a7169
|
@ -93,7 +93,6 @@ class TestVSCSIAdapter(test.TestCase):
|
|||
'id')
|
||||
instance.system_metadata = {volid_meta_key: self.udid}
|
||||
# Set test scenario
|
||||
CONF.enable_remove_hdisk = False
|
||||
self.adpt.read.return_value = self.vios_feed_resp
|
||||
mock_hdisk_from_uuid.return_value = 'device_name'
|
||||
mock_get_vm_id.return_value = 'partion_id'
|
||||
|
@ -102,8 +101,7 @@ class TestVSCSIAdapter(test.TestCase):
|
|||
'vm_uuid',
|
||||
instance, con_info)
|
||||
self.assertEqual(1, mock_remove_pv_mapping.call_count)
|
||||
# Per conf setting remove_hdisk not called
|
||||
self.assertEqual(0, mock_remove_hdisk.call_count)
|
||||
self.assertEqual(1, mock_remove_hdisk.call_count)
|
||||
# Verify entry deleted
|
||||
self.assertDictEqual({}, instance.system_metadata)
|
||||
|
||||
|
|
|
@ -31,11 +31,6 @@ from pypowervm.wrappers import storage as pvm_stor
|
|||
import six
|
||||
|
||||
CONF = cfg.CONF
|
||||
CONF.register_opts([
|
||||
cfg.BoolOpt('enable_hdisk_removal', default=False,
|
||||
help='Automatically allow the system to remove '
|
||||
'the associated hdisk when a volume is '
|
||||
'disconnected.')])
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
||||
|
@ -207,10 +202,17 @@ class VscsiVolumeAdapter(v_driver.FibreChannelVolumeAdapter):
|
|||
tsk_map.remove_pv_mapping(adapter, vio_wrap.uuid,
|
||||
partition_id, device_name)
|
||||
|
||||
# TODO(IBM): New method coming to support remove hdisk
|
||||
if CONF.enable_hdisk_removal:
|
||||
hdisk.remove_hdisk(adapter, CONF.host,
|
||||
device_name, vio_wrap.uuid)
|
||||
try:
|
||||
# Attempt to remove the hDisk
|
||||
hdisk.remove_hdisk(adapter, CONF.host, device_name,
|
||||
vio_wrap.uuid)
|
||||
except Exception as e:
|
||||
# If there is a failure, log it, but don't stop the process
|
||||
msg = (_LW("There was an error removing the hdisk "
|
||||
"%(disk)s from the Virtual I/O Server.") %
|
||||
{'disk': device_name})
|
||||
LOG.warn(msg)
|
||||
LOG.warn(e)
|
||||
|
||||
# Disconnect volume complete, now remove key
|
||||
self._delete_udid_key(instance, vio_wrap.uuid, volume_id)
|
||||
|
|
Loading…
Reference in New Issue