From: ubaumann Date: Wed, 22 Jul 2015 17:25:47 +0000 (+0200) Subject: NetApp ESeries: fix delete of non-existent volume X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=eccf433fd716ac5f61cafbb490ddeed0a6827531;p=openstack-build%2Fcinder-build.git NetApp ESeries: fix delete of non-existent volume If a non existing volume is deleted the NetApp iSCSI eseries driver throws a KeyError Exception in the delete_volume method. This situation can occur if the user manually deletes a LUN in the NetApp controller directly or if the delete operation initiated via cinder is interrupted, which leaves the system in an inconsistent state. For example if the volume is deleted on the NetApp controller but still residing in the OpenStack database. Change-Id: I4e9388c620556ed042b7e3fe59b550871df5b563 Closes-Bug: #1477027 --- diff --git a/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py b/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py index 12cd23509..cb31ea016 100644 --- a/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py +++ b/cinder/tests/unit/volume/drivers/netapp/eseries/test_library.py @@ -773,6 +773,20 @@ class NetAppEseriesLibraryMultiAttachTestCase(test.TestCase): # Ensure the volume we created is not cleaned up self.assertEqual(0, self.library._client.delete_volume.call_count) + def test_get_non_existing_volume_raises_keyerror(self): + volume2 = get_fake_volume() + # Change to a nonexistent id. + volume2['name_id'] = '88888888-4444-4444-4444-cccccccccccc' + self.assertRaises(KeyError, + self.library._get_volume, + volume2['name_id']) + + def test_delete_non_existing_volume(self): + volume2 = get_fake_volume() + # Change to a nonexistent id. + volume2['name_id'] = '88888888-4444-4444-4444-cccccccccccc' + self.assertIsNone(self.library.delete_volume(volume2)) + def test_map_volume_to_host_volume_not_mapped(self): """Map the volume directly to destination host.""" self.mock_object(self.library._client, diff --git a/cinder/volume/drivers/netapp/eseries/library.py b/cinder/volume/drivers/netapp/eseries/library.py index 84d8c85d7..2e3d5f203 100644 --- a/cinder/volume/drivers/netapp/eseries/library.py +++ b/cinder/volume/drivers/netapp/eseries/library.py @@ -475,7 +475,7 @@ class NetAppESeriesLibrary(object): try: vol = self._get_volume(volume['name_id']) self._client.delete_volume(vol['volumeRef']) - except exception.NetAppDriverException: + except (exception.NetAppDriverException, KeyError): LOG.warning(_LI("Volume %s already deleted."), volume['id']) return