From 205bac3caf5ff983c60da0d171e51c1cc286024a Mon Sep 17 00:00:00 2001 From: Rajat Dhasmana Date: Mon, 1 Jul 2024 21:04:45 +0530 Subject: [PATCH] Fix: incremental volume backup The incremental volume backup stopped working after we moved from cinderclient to SDK[1]. This happened because SDK accepts the ``is_incremental`` parameter[2] rather than the ``incremental`` parameter which is actually passed in the API request and was previously a valid parameter for cinderclient. This patch fixes the issue by passing the ``is_incremental`` field instead of ``incremental`` from the OSC side which adds the ``incremental`` parameter in the API request. Request body after the fix: '{"backup": {"name": null, "description": null, "volume_id": "", "force": false, "container": null, "incremental": true}}' [1] https://review.opendev.org/c/openstack/python-openstackclient/+/889748 [2] https://opendev.org/openstack/openstacksdk/src/commit/10e5e20fc0eb5264080f0cfdc0523d65883dc693/openstack/block_storage/v2/backup.py#L126-L134 Closes-Bug: #2070080 Change-Id: I89bd3d2751267ec39f4dbd664b7873ab87a9ac6c --- .../tests/unit/volume/v2/test_volume_backup.py | 8 ++++---- openstackclient/volume/v2/volume_backup.py | 2 +- .../notes/fix-backup-incremental-d1c1e6886cf32256.yaml | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/fix-backup-incremental-d1c1e6886cf32256.yaml diff --git a/openstackclient/tests/unit/volume/v2/test_volume_backup.py b/openstackclient/tests/unit/volume/v2/test_volume_backup.py index aa0c050cdc..e16bdbb81f 100644 --- a/openstackclient/tests/unit/volume/v2/test_volume_backup.py +++ b/openstackclient/tests/unit/volume/v2/test_volume_backup.py @@ -120,7 +120,7 @@ class TestBackupCreate(TestBackup): name=self.new_backup.name, description=self.new_backup.description, force=True, - incremental=True, + is_incremental=True, snapshot_id=self.new_backup.snapshot_id, ) self.assertEqual(self.columns, columns) @@ -150,7 +150,7 @@ class TestBackupCreate(TestBackup): name=None, description=None, force=False, - incremental=False, + is_incremental=False, metadata={"foo": "bar", "wow": "much-cool"}, ) self.assertEqual(self.columns, columns) @@ -199,7 +199,7 @@ class TestBackupCreate(TestBackup): name=None, description=None, force=False, - incremental=False, + is_incremental=False, availability_zone="my-az", ) self.assertEqual(self.columns, columns) @@ -247,7 +247,7 @@ class TestBackupCreate(TestBackup): name=None, description=self.new_backup.description, force=False, - incremental=False, + is_incremental=False, ) self.assertEqual(self.columns, columns) self.assertEqual(self.data, data) diff --git a/openstackclient/volume/v2/volume_backup.py b/openstackclient/volume/v2/volume_backup.py index 7eed05a1db..a4e6ac85a3 100644 --- a/openstackclient/volume/v2/volume_backup.py +++ b/openstackclient/volume/v2/volume_backup.py @@ -173,7 +173,7 @@ class CreateVolumeBackup(command.ShowOne): name=parsed_args.name, description=parsed_args.description, force=parsed_args.force, - incremental=parsed_args.incremental, + is_incremental=parsed_args.incremental, **kwargs, ) data = utils.get_dict_properties(backup, columns) diff --git a/releasenotes/notes/fix-backup-incremental-d1c1e6886cf32256.yaml b/releasenotes/notes/fix-backup-incremental-d1c1e6886cf32256.yaml new file mode 100644 index 0000000000..7942a6f293 --- /dev/null +++ b/releasenotes/notes/fix-backup-incremental-d1c1e6886cf32256.yaml @@ -0,0 +1,7 @@ +--- +fixes: + - | + Fixed issue with creating incremental volume backup. + Previously, ``incremental`` value was not passed in the + API request which is now included in the backup + create request.