From 2e031e1cacd914a18a6d5f279177f6eeba2f2d46 Mon Sep 17 00:00:00 2001 From: Pete Zaitcev Date: Sat, 1 Jul 2023 01:30:55 -0500 Subject: [PATCH] Fix a regression in restoring to sparse volumes Unfortunately, the commit b75c29c7d8e0e6ac212b59f9ad8d140874e55251 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 --- cinder/tests/unit/volume/flows/test_create_volume_flow.py | 8 ++++---- cinder/volume/flows/manager/create_volume.py | 2 +- releasenotes/notes/backup-sparse-f685f4321f2994f5.yaml | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/backup-sparse-f685f4321f2994f5.yaml diff --git a/cinder/tests/unit/volume/flows/test_create_volume_flow.py b/cinder/tests/unit/volume/flows/test_create_volume_flow.py index d2dca5a56bf..1bb3f2b9800 100644 --- a/cinder/tests/unit/volume/flows/test_create_volume_flow.py +++ b/cinder/tests/unit/volume/flows/test_create_volume_flow.py @@ -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) diff --git a/cinder/volume/flows/manager/create_volume.py b/cinder/volume/flows/manager/create_volume.py index 905258bf42b..ac09ed898a3 100644 --- a/cinder/volume/flows/manager/create_volume.py +++ b/cinder/volume/flows/manager/create_volume.py @@ -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 " diff --git a/releasenotes/notes/backup-sparse-f685f4321f2994f5.yaml b/releasenotes/notes/backup-sparse-f685f4321f2994f5.yaml new file mode 100644 index 00000000000..20c7e708772 --- /dev/null +++ b/releasenotes/notes/backup-sparse-f685f4321f2994f5.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + `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.