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
This commit is contained in:
whoami-rajat 2021-10-05 01:43:18 -04:00
parent 91d0a6512f
commit 862edca0de
3 changed files with 11 additions and 3 deletions

View File

@ -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()

View File

@ -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)

View File

@ -0,0 +1,6 @@
---
fixes:
- |
NFS driver `bug #1946059
<https://bugs.launchpad.net/cinder/+bug/1946059>`_: Fixed
revert to snapshot operation.