Clear correct device when deleting a ThinLVM snap
The LVM driver tries to wipe a device using dd when a snapshot is deleted. For ThinLVM, it is attempting to wipe the /dev/mapper/cinder--volumes-<vol>-cow device, which does not exist for ThinLVM. This causes snapshot deletion to fail for ThinLVM if volume clearing is on. When using ThinLVM, only wipe the LV device rather than attempting to wipe the -cow device. This bug is only present in stable/grizzly (2013.1.4). It does not exist in stable/havana or master due to these changes:f702fe7
Fix secure delete for thick LVM snapshotsde43923
Don't zero out thin provisioned LV's on delete Closes-Bug: #1245529 Change-Id: I1d8dd618e51cc99b8947fbe0697a1c765c8251ba
This commit is contained in:
parent
03a54f9c15
commit
64878632a0
|
@ -956,6 +956,48 @@ class LVMVolumeDriverTestCase(DriverTestCase):
|
|||
volume = dict(fake_volume)
|
||||
self.assertEquals(None, lvm_driver.clear_volume(volume))
|
||||
|
||||
def test_clear_volume_thinlvm_snap(self):
|
||||
self.stubs.Set(os.path, 'exists', lambda x: True)
|
||||
configuration = conf.Configuration(fake_opt, 'fake_group')
|
||||
configuration.volume_clear = 'zero'
|
||||
configuration.volume_clear_size = 0
|
||||
configuration.volume_driver = \
|
||||
'cinder.volume.drivers.lvm.ThinLVMVolumeDriver'
|
||||
lvm_driver = lvm.ThinLVMVolumeDriver(configuration=configuration)
|
||||
|
||||
def fake_copy_volume(srcstr, deststr, size, **kwargs):
|
||||
self.assertEqual(deststr, '/dev/mapper/cinder--volumes-snap1')
|
||||
return True
|
||||
|
||||
self.stubs.Set(lvm_driver, '_copy_volume', fake_copy_volume)
|
||||
|
||||
fake_snapshot = {'name': 'snap1',
|
||||
'id': 'snap1',
|
||||
'size': 123}
|
||||
|
||||
lvm_driver.clear_volume(fake_snapshot, is_snapshot=True)
|
||||
|
||||
def test_clear_volume_lvm_snap(self):
|
||||
self.stubs.Set(os.path, 'exists', lambda x: True)
|
||||
configuration = conf.Configuration(fake_opt, 'fake_group')
|
||||
configuration.volume_clear = 'zero'
|
||||
configuration.volume_clear_size = 0
|
||||
configuration.volume_driver = \
|
||||
'cinder.volume.drivers.lvm.LVMISCSIDriver'
|
||||
lvm_driver = lvm.LVMISCSIDriver(configuration=configuration)
|
||||
|
||||
def fake_copy_volume(srcstr, deststr, size, **kwargs):
|
||||
self.assertEqual(deststr, '/dev/mapper/cinder--volumes-snap1-cow')
|
||||
return True
|
||||
|
||||
self.stubs.Set(lvm_driver, '_copy_volume', fake_copy_volume)
|
||||
|
||||
fake_snapshot = {'name': 'snap1',
|
||||
'id': 'snap1',
|
||||
'size': 123}
|
||||
|
||||
lvm_driver.clear_volume(fake_snapshot, is_snapshot=True)
|
||||
|
||||
|
||||
class ISCSITestCase(DriverTestCase):
|
||||
"""Test Case for ISCSIDriver"""
|
||||
|
|
|
@ -185,7 +185,9 @@ class LVMVolumeDriver(driver.VolumeDriver):
|
|||
if self.configuration.volume_clear == 'none':
|
||||
return
|
||||
|
||||
if is_snapshot:
|
||||
if is_snapshot and (
|
||||
self.configuration.volume_driver !=
|
||||
'cinder.volume.drivers.lvm.ThinLVMVolumeDriver'):
|
||||
# if the volume to be cleared is a snapshot of another volume
|
||||
# we need to clear out the volume using the -cow instead of the
|
||||
# directly volume path.
|
||||
|
|
Loading…
Reference in New Issue