]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
NetApp ESeries: fix delete of non-existent volume
authorubaumann <openstack@m.ubaumann.ch>
Wed, 22 Jul 2015 17:25:47 +0000 (19:25 +0200)
committerTom Barron <tpb@dyncloud.net>
Fri, 24 Jul 2015 11:43:36 +0000 (11:43 +0000)
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

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

index 12cd23509fbb81d54645cd822ab32b02845e65a1..cb31ea016a2136ea75f55b386d383c4cc30bca92 100644 (file)
@@ -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,
index 84d8c85d75122f415d6688d6de5233838385fba0..2e3d5f203b37a0ac9b883145fc95f0d46209097e 100644 (file)
@@ -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