Allow creating volumes from snapshots during backups for Quobyte
Allows to create a volume from a snapshot while the snapshot itself is in the state 'backing-up'. Moves the corresponding unit tests to ddt to extend coverage while reducing code size. Partial-Bug: #1703405 Change-Id: If4fe96ac59c975ba71c4387004d7454cb293b972
This commit is contained in:
parent
674b86a5da
commit
06b9e3c498
|
@ -1189,8 +1189,10 @@ class QuobyteDriverTestCase(test.TestCase):
|
|||
shutil.copyfile.assert_called_once_with(cache_path, dest_vol_path)
|
||||
drv._set_rw_permissions.assert_called_once_with(dest_vol_path)
|
||||
|
||||
def test_create_volume_from_snapshot_status_not_available(self):
|
||||
"""Expect an error when the snapshot's status is not 'available'."""
|
||||
@ddt.data(['available', True], ['backing-up', True],
|
||||
['creating', False], ['deleting', False])
|
||||
@ddt.unpack
|
||||
def test_create_volume_from_snapshot(self, state, should_work):
|
||||
drv = self._driver
|
||||
|
||||
src_volume = self._simple_volume()
|
||||
|
@ -1202,29 +1204,7 @@ class QuobyteDriverTestCase(test.TestCase):
|
|||
volume_size=src_volume.size,
|
||||
volume_id=src_volume.id,
|
||||
id=self.SNAP_UUID,
|
||||
status='error')
|
||||
snap_ref.volume = src_volume
|
||||
|
||||
new_volume = self._simple_volume(size=snap_ref.volume_size)
|
||||
|
||||
self.assertRaises(exception.InvalidSnapshot,
|
||||
drv.create_volume_from_snapshot,
|
||||
new_volume,
|
||||
snap_ref)
|
||||
|
||||
def test_create_volume_from_snapshot(self):
|
||||
drv = self._driver
|
||||
|
||||
src_volume = self._simple_volume()
|
||||
|
||||
snap_ref = fake_snapshot.fake_snapshot_obj(
|
||||
self.context,
|
||||
volume_name=src_volume.name,
|
||||
display_name='clone-snap-%s' % src_volume.id,
|
||||
volume_size=src_volume.size,
|
||||
volume_id=src_volume.id,
|
||||
id=self.SNAP_UUID,
|
||||
status='available')
|
||||
status=state)
|
||||
snap_ref.volume = src_volume
|
||||
|
||||
new_volume = self._simple_volume(size=snap_ref.volume_size)
|
||||
|
@ -1233,12 +1213,18 @@ class QuobyteDriverTestCase(test.TestCase):
|
|||
drv._find_share = mock.Mock(return_value=self.TEST_QUOBYTE_VOLUME)
|
||||
drv._copy_volume_from_snapshot = mock.Mock()
|
||||
|
||||
drv.create_volume_from_snapshot(new_volume, snap_ref)
|
||||
if should_work:
|
||||
drv.create_volume_from_snapshot(new_volume, snap_ref)
|
||||
|
||||
drv._ensure_shares_mounted.assert_called_once_with()
|
||||
drv._find_share.assert_called_once_with(new_volume)
|
||||
(drv._copy_volume_from_snapshot.
|
||||
assert_called_once_with(snap_ref, new_volume, new_volume['size']))
|
||||
drv._ensure_shares_mounted.assert_called_once_with()
|
||||
drv._find_share.assert_called_once_with(new_volume)
|
||||
(drv._copy_volume_from_snapshot.
|
||||
assert_called_once_with(snap_ref, new_volume, new_volume['size']))
|
||||
else:
|
||||
self.assertRaises(exception.InvalidSnapshot,
|
||||
drv.create_volume_from_snapshot,
|
||||
new_volume,
|
||||
snap_ref)
|
||||
|
||||
def test_initialize_connection(self):
|
||||
drv = self._driver
|
||||
|
|
|
@ -35,7 +35,7 @@ from cinder import utils
|
|||
from cinder.volume import configuration
|
||||
from cinder.volume.drivers import remotefs as remotefs_drv
|
||||
|
||||
VERSION = '1.1.12'
|
||||
VERSION = '1.1.13'
|
||||
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
|
@ -115,6 +115,7 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
|
|||
1.1.10 - Adds overlay based volumes for snapshot merge caching
|
||||
1.1.11 - NAS secure ownership & permissions are now False by default
|
||||
1.1.12 - Ensure the currently configured volume url is always used
|
||||
1.1.13 - Enable snapshot based backups with Quobyte
|
||||
|
||||
"""
|
||||
|
||||
|
@ -347,9 +348,9 @@ class QuobyteDriver(remotefs_drv.RemoteFSSnapDriverDistributed):
|
|||
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}
|
||||
if snapshot.status not in ['available', 'backing-up']:
|
||||
msg = _('Snapshot status must be "available" or "backing-up" to '
|
||||
'clone. But is: %(status)s') % {'status': snapshot.status}
|
||||
|
||||
raise exception.InvalidSnapshot(msg)
|
||||
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
fixes:
|
||||
- |
|
||||
Fixes a bug that prevented creation of Quobyte volumes from
|
||||
snapshots during snapshot backups. This now allows backing up
|
||||
volumes with existing snapshots.
|
Loading…
Reference in New Issue