diff options
author | Zuul <zuul@review.opendev.org> | 2021-02-24 04:00:00 +0000 |
---|---|---|
committer | Gerrit Code Review <review@openstack.org> | 2021-02-24 04:00:00 +0000 |
commit | ecd2916042d009a93bc7b4b7f1d66548aa89b121 (patch) | |
tree | 19e8515fa981021ff5620ce4cf066de0057bbc0b | |
parent | 22eaeb5550378b5fbd09a6602ae36fc7fef17d78 (diff) | |
parent | 04198bba821d1fe77b35080ba2be0516ab262924 (diff) | |
download | cinder-ecd2916042d009a93bc7b4b7f1d66548aa89b121.tar.gz |
Merge "Fixed an issue with creating a backup from snapshot with NFS volume driver." into stable/train
-rw-r--r-- | cinder/tests/unit/volume/drivers/test_nfs.py | 18 | ||||
-rw-r--r-- | cinder/volume/drivers/remotefs.py | 10 | ||||
-rw-r--r-- | releasenotes/notes/bug-1888951-backup-from-nfs-snapshot-2e06235eb318b852.yaml | 6 |
3 files changed, 22 insertions, 12 deletions
diff --git a/cinder/tests/unit/volume/drivers/test_nfs.py b/cinder/tests/unit/volume/drivers/test_nfs.py index b4ac4bfd8..1b2acb83d 100644 --- a/cinder/tests/unit/volume/drivers/test_nfs.py +++ b/cinder/tests/unit/volume/drivers/test_nfs.py @@ -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'] diff --git a/cinder/volume/drivers/remotefs.py b/cinder/volume/drivers/remotefs.py index 1e5dde3e8..e27a44bca 100644 --- a/cinder/volume/drivers/remotefs.py +++ b/cinder/volume/drivers/remotefs.py @@ -1258,11 +1258,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() diff --git a/releasenotes/notes/bug-1888951-backup-from-nfs-snapshot-2e06235eb318b852.yaml b/releasenotes/notes/bug-1888951-backup-from-nfs-snapshot-2e06235eb318b852.yaml new file mode 100644 index 000000000..3f63402b5 --- /dev/null +++ b/releasenotes/notes/bug-1888951-backup-from-nfs-snapshot-2e06235eb318b852.yaml @@ -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. |