From e7090a7169d4f7b9731a7cd1d20b0891202b8d21 Mon Sep 17 00:00:00 2001 From: Drew Thorstensen Date: Fri, 1 May 2015 07:36:57 -0500 Subject: [PATCH] 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 --- .../tests/virt/powervm/volume/test_vscsi.py | 4 +--- nova_powervm/virt/powervm/volume/vscsi.py | 20 ++++++++++--------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/nova_powervm/tests/virt/powervm/volume/test_vscsi.py b/nova_powervm/tests/virt/powervm/volume/test_vscsi.py index 34c0687d..4509fe98 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_vscsi.py +++ b/nova_powervm/tests/virt/powervm/volume/test_vscsi.py @@ -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) diff --git a/nova_powervm/virt/powervm/volume/vscsi.py b/nova_powervm/virt/powervm/volume/vscsi.py index 9fea0720..b9f35325 100644 --- a/nova_powervm/virt/powervm/volume/vscsi.py +++ b/nova_powervm/virt/powervm/volume/vscsi.py @@ -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)