Merge "Backup manager: Synchronously call remove_export_snapshot"

This commit is contained in:
Zuul 2021-04-13 01:40:01 +00:00 committed by Gerrit Code Review
commit c12375fec6
3 changed files with 11 additions and 4 deletions

View File

@ -1072,7 +1072,7 @@ class BackupManager(manager.SchedulerDependentManager):
else:
rpcapi.terminate_connection_snapshot(ctxt, device,
properties, force=force)
rpcapi.remove_export_snapshot(ctxt, device)
rpcapi.remove_export_snapshot(ctxt, device, sync=True)
def is_working(self):
return self.is_initialized

View File

@ -901,6 +901,7 @@ class BackupTestCase(BaseBackupTest):
self.assertRaises(exception.InvalidSnapshot,
self.backup_mgr.create_backup, self.ctxt, backup)
@mock.patch('cinder.volume.rpcapi.VolumeAPI.remove_export_snapshot')
@mock.patch('cinder.volume.volume_utils.brick_get_connector_properties')
@mock.patch('cinder.volume.rpcapi.VolumeAPI.get_backup_device')
@mock.patch('cinder.utils.temporary_chown')
@ -910,7 +911,8 @@ class BackupTestCase(BaseBackupTest):
mock_open,
mock_temporary_chown,
mock_get_backup_device,
mock_get_conn):
mock_get_conn,
mock_remove_export_snapshot):
"""Test backup in-use volume using temp snapshot."""
self.override_config('backup_use_same_host', True)
vol_size = 1
@ -952,6 +954,8 @@ class BackupTestCase(BaseBackupTest):
mock_get_conn.assert_called_once_with()
mock_terminate_connection_snapshot.assert_called_once_with(
self.ctxt, snap, properties, force=True)
mock_remove_export_snapshot.assert_called_once_with(
self.ctxt, mock.ANY, sync=True)
vol = objects.Volume.get_by_id(self.ctxt, vol_id)
self.assertEqual('in-use', vol['status'])
self.assertEqual('backing-up', vol['previous_status'])

View File

@ -438,8 +438,11 @@ class VolumeAPI(rpc.RPCAPI):
connector=connector, force=force)
@rpc.assert_min_rpc_version('3.13')
def remove_export_snapshot(self, ctxt, snapshot):
def remove_export_snapshot(self, ctxt, snapshot, sync=False):
cctxt = self._get_cctxt(snapshot.service_topic_queue, version='3.13')
if sync:
cctxt.call(ctxt, 'remove_export_snapshot', snapshot_id=snapshot.id)
else:
cctxt.cast(ctxt, 'remove_export_snapshot', snapshot_id=snapshot.id)
@rpc.assert_min_rpc_version('3.9')