Merge "RBD: delete snapshots if missing in the backend"

This commit is contained in:
Jenkins 2016-04-15 17:36:16 +00:00 committed by Gerrit Code Review
commit 5327c52279
2 changed files with 26 additions and 4 deletions

View File

@ -421,6 +421,21 @@ class RBDTestCase(test.TestCase):
proxy.remove_snap.assert_called_with(self.snapshot.name)
proxy.unprotect_snap.assert_called_with(self.snapshot.name)
@common_mocks
@mock.patch('cinder.objects.Volume.get_by_id')
def test_delete_notfound_on_remove_snapshot(self, volume_get_by_id):
volume_get_by_id.return_value = self.volume_a
proxy = self.mock_proxy.return_value
proxy.__enter__.return_value = proxy
proxy.remove_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
@mock.patch('cinder.objects.Volume.get_by_id')
def test_delete_unprotected_snapshot(self, volume_get_by_id):

View File

@ -763,10 +763,13 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
try:
volume.unprotect_snap(snap_name)
except self.rbd.InvalidArgument:
LOG.info(_LI("Unable to unprotect snapshot %s."), snap_name)
LOG.info(
_LI("InvalidArgument: Unable to unprotect snapshot %s."),
snap_name)
except self.rbd.ImageNotFound:
LOG.info(_LI("Snapshot %s does not exist in backend."),
snap_name)
LOG.info(
_LI("ImageNotFound: Unable to unprotect snapshot %s."),
snap_name)
except self.rbd.ImageBusy:
children_list = self._get_children_info(volume, snap_name)
@ -779,7 +782,11 @@ class RBDDriver(driver.TransferVD, driver.ExtendVD,
'snap': snap_name})
raise exception.SnapshotIsBusy(snapshot_name=snap_name)
volume.remove_snap(snap_name)
try:
volume.remove_snap(snap_name)
except self.rbd.ImageNotFound:
LOG.info(_LI("Snapshot %s does not exist in backend."),
snap_name)
def retype(self, context, volume, new_type, diff, host):
"""Retypes a volume, allow Qos and extra_specs change."""