From 862edca0deb366ea980485359216fea020a03c9e Mon Sep 17 00:00:00 2001 From: whoami-rajat Date: Tue, 5 Oct 2021 01:43:18 -0400 Subject: [PATCH] NFS: Fix generic revert to snapshot flow While reverting to a snapshot with generic flow, we create a temporary volume from snapshot and copy data from temporary to the original volume. While creating this temporary volume, the snapshot is in 'restoring' state whereas the remotefs driver only accepts 'available' and 'backing-up' states for this operation. This patch adds the 'restoring' state to the list of acceptable states. Closes-Bug: 1946059 Change-Id: Id1e40fd42b88c63dbbba2aaae77c40660ddac4c7 --- cinder/tests/unit/volume/drivers/test_nfs.py | 6 ++++-- cinder/volume/drivers/remotefs.py | 2 +- .../notes/fix-nfs-revert-to-snap-adc04204b3661d66.yaml | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 releasenotes/notes/fix-nfs-revert-to-snap-adc04204b3661d66.yaml diff --git a/cinder/tests/unit/volume/drivers/test_nfs.py b/cinder/tests/unit/volume/drivers/test_nfs.py index fb3481f4387..ad80fc11c3f 100644 --- a/cinder/tests/unit/volume/drivers/test_nfs.py +++ b/cinder/tests/unit/volume/drivers/test_nfs.py @@ -1367,8 +1367,10 @@ class NfsDriverTestCase(test.TestCase): @ddt.data([NFS_CONFIG1, QEMU_IMG_INFO_OUT3, 'available'], [NFS_CONFIG2, QEMU_IMG_INFO_OUT4, 'backing-up'], + [NFS_CONFIG2, QEMU_IMG_INFO_OUT4, 'restoring'], [NFS_CONFIG3, QEMU_IMG_INFO_OUT3, 'available'], - [NFS_CONFIG4, QEMU_IMG_INFO_OUT4, 'backing-up']) + [NFS_CONFIG4, QEMU_IMG_INFO_OUT4, 'backing-up'], + [NFS_CONFIG4, QEMU_IMG_INFO_OUT4, 'restoring']) @ddt.unpack @mock.patch('cinder.objects.volume.Volume.save') def test_create_volume_from_snapshot(self, nfs_conf, qemu_img_info, @@ -1433,7 +1435,7 @@ class NfsDriverTestCase(test.TestCase): mock_find_share.assert_called_once_with(new_volume) @ddt.data('error', 'creating', 'deleting', 'deleted', 'updating', - 'error_deleting', 'unmanaging', 'restoring') + 'error_deleting', 'unmanaging') def test_create_volume_from_snapshot_invalid_status(self, snap_status): """Expect an error when the snapshot's status is not 'available'.""" self._set_driver() diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py index 528e3afd03f..0383c9d6ae0 100644 --- a/cinder/volume/drivers/remotefs.py +++ b/cinder/volume/drivers/remotefs.py @@ -1393,7 +1393,7 @@ class RemoteFSSnapDriverBase(RemoteFSDriver): {'vol': volume.id, 'snap': snapshot.id}) status = snapshot.status - acceptable_states = ['available', 'backing-up'] + acceptable_states = ['available', 'backing-up', 'restoring'] self._validate_state(status, acceptable_states, obj_description='snapshot', invalid_exc=exception.InvalidSnapshot) diff --git a/releasenotes/notes/fix-nfs-revert-to-snap-adc04204b3661d66.yaml b/releasenotes/notes/fix-nfs-revert-to-snap-adc04204b3661d66.yaml new file mode 100644 index 00000000000..dd9865f50ad --- /dev/null +++ b/releasenotes/notes/fix-nfs-revert-to-snap-adc04204b3661d66.yaml @@ -0,0 +1,6 @@ +--- +fixes: + - | + NFS driver `bug #1946059 + `_: Fixed + revert to snapshot operation.