From a70603af841afaf42aeb7396bf765ff5d32d7381 Mon Sep 17 00:00:00 2001 From: prashkre Date: Tue, 17 Apr 2018 16:40:12 +0530 Subject: [PATCH] Handle exceptions properly with iscsi discovery It fixes issues around exception handling when iscsi discovery fails. Change-Id: I875a41d3eb8d64851da8d1586f53c4f71436b9d0 Closes-bug: #1764682 (cherry picked from commit ec454b725da5505bacd02cfa352b5e77fe59b042) --- nova_powervm/tests/virt/powervm/volume/test_iscsi.py | 8 ++++---- nova_powervm/virt/powervm/volume/iscsi.py | 5 ++++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/nova_powervm/tests/virt/powervm/volume/test_iscsi.py b/nova_powervm/tests/virt/powervm/volume/test_iscsi.py index 49ebdf30..ed80c813 100644 --- a/nova_powervm/tests/virt/powervm/volume/test_iscsi.py +++ b/nova_powervm/tests/virt/powervm/volume/test_iscsi.py @@ -1,4 +1,4 @@ -# Copyright 2015, 2017 IBM Corp. +# Copyright 2015, 2018 IBM Corp. # # All Rights Reserved. # @@ -217,7 +217,7 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter): vios_uuid='fake_vios', status='fake_status') # Run the method - self.assertRaises(pvm_exc.MultipleExceptionsInFeedTask, + self.assertRaises(p_exc.VolumeAttachFailed, self.vol_drv.connect_volume, self.slot_mgr) @mock.patch('pypowervm.tasks.hdisk.discover_iscsi', autospec=True) @@ -228,8 +228,8 @@ class TestISCSIAdapter(test_vol.TestVolumeAdapter): operation_name='ISCSIDiscovery', error='fake_err') # Run the method - self.assertRaises(pvm_exc.MultipleExceptionsInFeedTask, - self.vol_drv.connect_volume, self.slot_mgr) + self.assertRaises(p_exc.VolumeAttachFailed, + self.multi_vol_drv.connect_volume, self.slot_mgr) @mock.patch('pypowervm.tasks.partition.get_active_vioses', autospec=True) @mock.patch('pypowervm.tasks.storage.rescan_vstor', autospec=True) diff --git a/nova_powervm/virt/powervm/volume/iscsi.py b/nova_powervm/virt/powervm/volume/iscsi.py index 23158e61..23bab07c 100644 --- a/nova_powervm/virt/powervm/volume/iscsi.py +++ b/nova_powervm/virt/powervm/volume/iscsi.py @@ -119,7 +119,10 @@ class IscsiVolumeAdapter(volume.VscsiVolumeAdapter, discovery_password=discovery_password, multipath=self._is_multipath()) except (pvm_exc.ISCSIDiscoveryFailed, pvm_exc.JobRequestFailed) as e: - LOG.warning(e) + msg_args = {'vios': vios_w.uuid, 'err': six.text_type(e)} + LOG.warning("iSCSI discovery on VIOS %(vios)s failed with " + "error: %(err)s", msg_args) + return None, None def _discover_volume_on_vios(self, vios_w): """Discovers an hdisk on a single vios for the volume.