From: Michael Price Date: Wed, 30 Sep 2015 18:56:56 +0000 (-0500) Subject: NetApp: E-Series fix deletion of missing volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=5cbf00b624e6c2bb8597d82640a1cb61b9405ba6;p=openstack-build%2Fcinder-build.git NetApp: E-Series fix deletion of missing volume When a Cinder volume is deleted but the backend volume is missing, an exception was being thrown, rather than swallowed and being logged. A KeyError was being expected, but a VolumeNotFound exception was actually being raised. This patch catches the VolumeNotFound exception, and logs a debug message if the volume could not be deleted from the backend (because it no longer exists). This patch restores compatibility with older versions where an exception would not be thrown. Closes-Bug: 1502166 Change-Id: I47a8d9b408fc4ac7fae30f043b0dfca0bb763d8d --- diff --git a/cinder/tests/unit/test_netapp_eseries_iscsi.py b/cinder/tests/unit/test_netapp_eseries_iscsi.py index dfe87fad5..359136196 100644 --- a/cinder/tests/unit/test_netapp_eseries_iscsi.py +++ b/cinder/tests/unit/test_netapp_eseries_iscsi.py @@ -976,18 +976,15 @@ class NetAppEseriesISCSIDriverTestCase(test.TestCase): def test_get_exist_vol_source_name_missing(self): self.library._client.list_volume = mock.Mock( - side_effect=exception.InvalidInput) + side_effect=exception.InvalidInput(message="")) self.assertRaises(exception.ManageExistingInvalidReference, self.library._get_existing_vol_with_manage_ref, {'id': '1234'}) @ddt.data('source-id', 'source-name') def test_get_exist_vol_source_not_found(self, attr_name): - def _get_volume(v_id): - d = {'id': '1', 'name': 'volume1', 'worldWideName': '0'} - return d[v_id] - - self.library._client.list_volume = mock.Mock(wraps=_get_volume) + self.library._client.list_volume = mock.Mock( + side_effect=exception.VolumeNotFound(message='Not Found')) self.assertRaises(exception.ManageExistingInvalidReference, self.library._get_existing_vol_with_manage_ref, {attr_name: 'name2'}) diff --git a/cinder/volume/drivers/netapp/eseries/library.py b/cinder/volume/drivers/netapp/eseries/library.py index 323af2d6c..591c5fe51 100644 --- a/cinder/volume/drivers/netapp/eseries/library.py +++ b/cinder/volume/drivers/netapp/eseries/library.py @@ -536,7 +536,7 @@ class NetAppESeriesLibrary(object): try: vol = self._get_volume(volume['name_id']) self._client.delete_volume(vol['volumeRef']) - except (exception.NetAppDriverException, KeyError): + except (exception.NetAppDriverException, exception.VolumeNotFound): LOG.warning(_LW("Volume %s already deleted."), volume['id']) return @@ -1255,7 +1255,7 @@ class NetAppESeriesLibrary(object): ' or source-id element.') raise exception.ManageExistingInvalidReference( existing_ref=existing_ref, reason=reason) - except KeyError: + except exception.VolumeNotFound: raise exception.ManageExistingInvalidReference( existing_ref=existing_ref, reason=_('Volume not found on configured storage pools.'))