Fix a regression in restoring to sparse volumes

Unfortunately, the commit b75c29c7d8
did not update all the places where BackupAPI.restore_backup()
was called. One of them was in the flow manager.

Although this regression being undetected in is disappointing,
we are not changing how unit tests are performed in any
fundamental way for this patch. An outstanding patch using
MyPy is aready in review, which would capture this case.

Closes-bug: #2025277
Related-Change-Id: I54b81a568a01af44e3f74bcac55e823cdae9bfbf
Change-Id: Iabfebacfea44916f89584ffd019d848e53302eaf
This commit is contained in:
Pete Zaitcev 2023-07-01 01:30:55 -05:00
parent c1a18fcdf9
commit 2e031e1cac
3 changed files with 12 additions and 5 deletions

View File

@ -1254,7 +1254,7 @@ class CreateVolumeFlowManagerTestCase(test.TestCase):
fake_driver = mock.MagicMock()
fake_volume_manager = mock.MagicMock()
backup_host = 'host@backend#pool'
fake_manager = create_volume_manager.CreateVolumeFromSpecTask(
test_manager = create_volume_manager.CreateVolumeFromSpecTask(
fake_volume_manager, fake_db, fake_driver)
volume_obj = fake_volume.fake_volume_obj(self.ctxt)
@ -1271,8 +1271,7 @@ class CreateVolumeFlowManagerTestCase(test.TestCase):
if driver_error:
fake_driver.create_volume_from_backup.side_effect = [
NotImplementedError]
fake_manager._create_from_backup(self.ctxt, volume_obj,
backup_obj.id)
test_manager._create_from_backup(self.ctxt, volume_obj, backup_obj.id)
fake_driver.create_volume_from_backup.assert_called_once_with(
volume_obj, backup_obj)
if driver_error:
@ -1282,7 +1281,8 @@ class CreateVolumeFlowManagerTestCase(test.TestCase):
mock_restore_backup.assert_called_once_with(self.ctxt,
backup_host,
backup_obj,
volume_obj['id'])
volume_obj['id'],
volume_is_new=True)
else:
fake_driver.create_volume_from_backup.assert_called_once_with(
volume_obj, backup_obj)

View File

@ -1172,7 +1172,7 @@ class CreateVolumeFromSpecTask(flow_utils.CinderTask):
backuprpcapi = backup_rpcapi.BackupAPI()
backuprpcapi.restore_backup(context, backup.host, backup,
volume.id)
volume.id, volume_is_new=True)
need_update_volume = False
LOG.info("Created volume %(volume_id)s from backup %(backup_id)s "

View File

@ -0,0 +1,7 @@
---
fixes:
- |
`Bug #2025277 <https://bugs.launchpad.net/cinder/+bug/2025277>`_:
Fixed a regression in the fix for Cinder backup restoring into
sparse volumes, where OpenStack's integrated CLI triggered a traceback.
The deprecated project-specific legacy CLI of Cinder continued to work.