]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp: E-Series fix deletion of missing volume
authorMichael Price <michael.price@netapp.com>
Wed, 30 Sep 2015 18:56:56 +0000 (13:56 -0500)
committerMichael Price <michael.price@netapp.com>
Fri, 16 Oct 2015 15:44:16 +0000 (15:44 +0000)
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

cinder/tests/unit/test_netapp_eseries_iscsi.py
cinder/volume/drivers/netapp/eseries/library.py

index dfe87fad58a671c36d9654b30e6cf0262b32c76c..35913619609bca108611fcece702e09598461696 100644 (file)
@@ -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'})
index 323af2d6c810f18d006384acac9ae613fa61ca1d..591c5fe51527344996449c9d504c680c457127de 100644 (file)
@@ -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.'))