Disable merge snapshot to volume for thin LVM
when lvm_type=thin in cinder.conf, merges a snapshot will result in other snapshots cannot be merged Change-Id: Ife3d57b6fe3717af02e7dfa440b1510058bfab40 Closes-Bug: #1702820
This commit is contained in:
parent
c38a946481
commit
c0d7402c2d
|
@ -722,6 +722,22 @@ class LVMVolumeDriverTestCase(test_driver.BaseDriverTestCase):
|
|||
self.volume.driver._escape_snapshot(fake_snapshot.name),
|
||||
fake_volume.name, self.configuration.lvm_type)
|
||||
|
||||
def test_revert_thin_snapshot(self):
|
||||
|
||||
configuration = conf.Configuration(fake_opt, 'fake_group')
|
||||
configuration.lvm_type = 'thin'
|
||||
lvm_driver = lvm.LVMVolumeDriver(configuration=configuration,
|
||||
db=db)
|
||||
fake_volume = tests_utils.create_volume(self.context,
|
||||
display_name='fake_volume')
|
||||
fake_snapshot = tests_utils.create_snapshot(
|
||||
self.context, fake_volume.id)
|
||||
|
||||
self.assertRaises(NotImplementedError,
|
||||
lvm_driver.revert_to_snapshot,
|
||||
self.context, fake_volume,
|
||||
fake_snapshot)
|
||||
|
||||
def test_lvm_manage_existing_snapshot_bad_size(self):
|
||||
"""Make sure correct exception on bad size returned from LVM.
|
||||
|
||||
|
|
|
@ -469,11 +469,18 @@ class LVMVolumeDriver(driver.VolumeDriver):
|
|||
def revert_to_snapshot(self, context, volume, snapshot):
|
||||
"""Revert a volume to a snapshot"""
|
||||
|
||||
self.vg.revert(self._escape_snapshot(snapshot.name))
|
||||
self.vg.deactivate_lv(volume.name)
|
||||
self.vg.activate_lv(volume.name)
|
||||
# Recreate the snapshot that was destroyed by the revert
|
||||
self.create_snapshot(snapshot)
|
||||
# NOTE(tommylikehu): We still can revert the volume because Cinder
|
||||
# will try the alternative approach if 'NotImplementedError'
|
||||
# is raised here.
|
||||
if self.configuration.lvm_type == 'thin':
|
||||
msg = _("Revert volume to snapshot not implemented for thin LVM.")
|
||||
raise NotImplementedError(msg)
|
||||
else:
|
||||
self.vg.revert(self._escape_snapshot(snapshot.name))
|
||||
self.vg.deactivate_lv(volume.name)
|
||||
self.vg.activate_lv(volume.name)
|
||||
# Recreate the snapshot that was destroyed by the revert
|
||||
self.create_snapshot(snapshot)
|
||||
|
||||
def local_path(self, volume, vg=None):
|
||||
if vg is None:
|
||||
|
|
Loading…
Reference in New Issue