]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
RBD: Make snapshot_delete more robust
authorDirk Mueller <dirk@dmllr.de>
Thu, 29 Jan 2015 13:11:35 +0000 (14:11 +0100)
committerSean McGinnis <sean_mcginnis@dell.com>
Wed, 25 Nov 2015 22:18:23 +0000 (16:18 -0600)
Since there is no equivalent of a force-snapshot-delete,
the normal snapshot-delete should be more robust to
also handle backend errors. In case the backend does not have
the image snapshot anymore, log an info message and succeed the
operation.

Change-Id: I7fe0878dbc07053ac78272b6998513fafa1c36e8
Closes-Bug: #1415905
Related-Bug: #1361926

cinder/tests/unit/test_rbd.py
cinder/volume/drivers/rbd.py

index 0cfc129c05706445b5b7074aceb27ab2d8009efb..91eeebe7d8194fbd07b0dbcbe8757a1fbf4b0fc1 100644 (file)
@@ -371,6 +371,19 @@ class RBDTestCase(test.TestCase):
         proxy.remove_snap.assert_called_with(self.snapshot_name)
         proxy.unprotect_snap.assert_called_with(self.snapshot_name)
 
+    @common_mocks
+    def test_delete_notfound_snapshot(self):
+        proxy = self.mock_proxy.return_value
+        proxy.__enter__.return_value = proxy
+
+        proxy.unprotect_snap.side_effect = (
+            self.mock_rbd.ImageNotFound)
+
+        self.driver.delete_snapshot(self.snapshot)
+
+        proxy.remove_snap.assert_called_with(self.snapshot_name)
+        proxy.unprotect_snap.assert_called_with(self.snapshot_name)
+
     @common_mocks
     def test_delete_busy_snapshot(self):
         proxy = self.mock_proxy.return_value
index c54aecbe29f0239833fb18836efc397a6c3fe678..1de8f3079e705599358af383c166e114a86c0662 100644 (file)
@@ -749,6 +749,9 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
         with RBDVolumeProxy(self, volume_name) as volume:
             try:
                 volume.unprotect_snap(snap_name)
+            except self.rbd.ImageNotFound:
+                LOG.info(_LI("Snapshot %s does not exist in backend."),
+                         snap_name)
             except self.rbd.ImageBusy:
                 children_list = self._get_children_info(volume, snap_name)