Backup manager: Synchronously call remove_export_snapshot

Similar to the fix in I482c3d552, wait for remove_export_snapshot()
to complete before returning from _detach_volume().

Related-Bug: #1920237
Change-Id: Ibf81c839fc9015051edcdb625e1018b817a9c675
This commit is contained in:
Eric Harney 2021-03-22 14:37:35 +00:00
parent d6895f9d2a
commit 5dea649c47
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,9 +438,12 @@ 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')
cctxt.cast(ctxt, 'remove_export_snapshot', snapshot_id=snapshot.id)
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')
def attachment_update(self, ctxt, vref, connector, attachment_id):