Merge "Fixed an issue with creating a backup from snapshot with NFS volume driver." into stable/ussuri

This commit is contained in:
Zuul 2021-02-15 17:16:46 +00:00 committed by Gerrit Code Review
commit d34e4d12fa
3 changed files with 22 additions and 12 deletions

View File

@ -1224,12 +1224,13 @@ class NfsDriverTestCase(test.TestCase):
run_as_root=True)
mock_permission.assert_called_once_with(dest_vol_path)
@ddt.data([NFS_CONFIG1, QEMU_IMG_INFO_OUT3],
[NFS_CONFIG2, QEMU_IMG_INFO_OUT4],
[NFS_CONFIG3, QEMU_IMG_INFO_OUT3],
[NFS_CONFIG4, QEMU_IMG_INFO_OUT4])
@ddt.data([NFS_CONFIG1, QEMU_IMG_INFO_OUT3, 'available'],
[NFS_CONFIG2, QEMU_IMG_INFO_OUT4, 'backing-up'],
[NFS_CONFIG3, QEMU_IMG_INFO_OUT3, 'available'],
[NFS_CONFIG4, QEMU_IMG_INFO_OUT4, 'backing-up'])
@ddt.unpack
def test_create_volume_from_snapshot(self, nfs_conf, qemu_img_info):
def test_create_volume_from_snapshot(self, nfs_conf, qemu_img_info,
snap_status):
self._set_driver(extra_confs=nfs_conf)
drv = self._driver
@ -1246,7 +1247,7 @@ class NfsDriverTestCase(test.TestCase):
# Fake snapshot based in the previous created volume
snap_file = src_volume.name + '.' + fake_snap.id
fake_snap.volume = src_volume
fake_snap.status = 'available'
fake_snap.status = snap_status
fake_snap.size = 10
# New fake volume where the snap will be copied
@ -1289,7 +1290,9 @@ class NfsDriverTestCase(test.TestCase):
mock_ensure.assert_called_once()
mock_find_share.assert_called_once_with(new_volume)
def test_create_volume_from_snapshot_status_not_available(self):
@ddt.data('error', 'creating', 'deleting', 'deleted', 'updating',
'error_deleting', 'unmanaging', 'restoring')
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()
drv = self._driver
@ -1298,6 +1301,7 @@ class NfsDriverTestCase(test.TestCase):
fake_snap = fake_snapshot.fake_snapshot_obj(self.context)
fake_snap.volume = src_volume
fake_snap.status = snap_status
new_volume = self._simple_volume()
new_volume['size'] = fake_snap['volume_size']

View File

@ -1260,11 +1260,11 @@ class RemoteFSSnapDriverBase(RemoteFSDriver):
LOG.debug('Creating volume %(vol)s from snapshot %(snap)s',
{'vol': volume.id, 'snap': snapshot.id})
if snapshot.status != 'available':
msg = _('Snapshot status must be "available" to clone. '
'But is: %(status)s') % {'status': snapshot.status}
raise exception.InvalidSnapshot(msg)
status = snapshot.status
acceptable_states = ['available', 'backing-up']
self._validate_state(status, acceptable_states,
obj_description='snapshot',
invalid_exc=exception.InvalidSnapshot)
self._ensure_shares_mounted()

View File

@ -0,0 +1,6 @@
---
fixes:
- |
`Bug #1888951 <https://bugs.launchpad.net/cinder/+bug/1888951>`_:
Fixed an issue with creating a backup from snapshot with NFS volume
driver.