RBD: delete snapshots if missing in the backend
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. A first attempt to fix this problem was found on https://review.openstack.org/#/c/151257/ This patch is already merged but it does not fix the problem completely. Change-Id: I1e80c2f71b79a5d40a0b7a42f03eb5bf911c24f0 Closes-Bug: #1415905
This commit is contained in:
parent
7811cb8d13
commit
677eb1c416
|
@ -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):
|
||||
|
|
|
@ -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."""
|
||||
|
|
Loading…
Reference in New Issue