Merge "GPFS Driver missing clone depth limit for snapshots"
This commit is contained in:
commit
180513d5e4
@ -203,8 +203,8 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
snapCount = len(db.snapshot_get_all_for_volume(self.context,
|
snapCount = len(db.snapshot_get_all_for_volume(self.context,
|
||||||
volume_src['id']))
|
volume_src['id']))
|
||||||
self.assertTrue(snapCount == 1)
|
self.assertTrue(snapCount == 1)
|
||||||
self.volume.delete_volume(self.context, volume_src['id'])
|
|
||||||
self.volume.delete_snapshot(self.context, snapshot_id)
|
self.volume.delete_snapshot(self.context, snapshot_id)
|
||||||
|
self.volume.delete_volume(self.context, volume_src['id'])
|
||||||
self.assertFalse(os.path.exists(os.path.join(self.volumes_path,
|
self.assertFalse(os.path.exists(os.path.join(self.volumes_path,
|
||||||
snapshot['name'])))
|
snapshot['name'])))
|
||||||
snapCount = len(db.snapshot_get_all_for_volume(self.context,
|
snapCount = len(db.snapshot_get_all_for_volume(self.context,
|
||||||
@ -231,8 +231,8 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
volume_dst['id']).snapshot_id)
|
volume_dst['id']).snapshot_id)
|
||||||
self.volume.delete_volume(self.context, volume_dst['id'])
|
self.volume.delete_volume(self.context, volume_dst['id'])
|
||||||
|
|
||||||
self.volume.delete_volume(self.context, volume_src['id'])
|
|
||||||
self.volume.delete_snapshot(self.context, snapshot_id)
|
self.volume.delete_snapshot(self.context, snapshot_id)
|
||||||
|
self.volume.delete_volume(self.context, volume_src['id'])
|
||||||
|
|
||||||
def test_create_cloned_volume(self):
|
def test_create_cloned_volume(self):
|
||||||
volume_src = test_utils.create_volume(self.context, host=CONF.host)
|
volume_src = test_utils.create_volume(self.context, host=CONF.host)
|
||||||
@ -269,9 +269,9 @@ class GPFSDriverTestCase(test.TestCase):
|
|||||||
volumepath = os.path.join(self.volumes_path, volume_dst['name'])
|
volumepath = os.path.join(self.volumes_path, volume_dst['name'])
|
||||||
self.assertTrue(os.path.exists(volumepath))
|
self.assertTrue(os.path.exists(volumepath))
|
||||||
|
|
||||||
|
self.volume.delete_snapshot(self.context, snapshot_id)
|
||||||
self.volume.delete_volume(self.context, volume_dst['id'])
|
self.volume.delete_volume(self.context, volume_dst['id'])
|
||||||
self.volume.delete_volume(self.context, volume_src['id'])
|
self.volume.delete_volume(self.context, volume_src['id'])
|
||||||
self.volume.delete_snapshot(self.context, snapshot_id)
|
|
||||||
|
|
||||||
def test_clone_image_to_volume_with_copy_on_write_mode(self):
|
def test_clone_image_to_volume_with_copy_on_write_mode(self):
|
||||||
"""Test the function of copy_image_to_volume
|
"""Test the function of copy_image_to_volume
|
||||||
|
@ -323,7 +323,7 @@ class GPFSDriver(driver.VolumeDriver):
|
|||||||
# would succeed and the snapshot is deleted.
|
# would succeed and the snapshot is deleted.
|
||||||
if not os.path.exists(fchild) and fparent:
|
if not os.path.exists(fchild) and fparent:
|
||||||
fpbase = os.path.basename(fparent)
|
fpbase = os.path.basename(fparent)
|
||||||
if (fpbase.startswith('snapshot-') or fpbase.endswith('.snap')):
|
if (fpbase.endswith('.snap') or fpbase.endswith('.ts')):
|
||||||
self._delete_gpfs_file(fparent)
|
self._delete_gpfs_file(fparent)
|
||||||
|
|
||||||
def delete_volume(self, volume):
|
def delete_volume(self, volume):
|
||||||
@ -381,11 +381,20 @@ class GPFSDriver(driver.VolumeDriver):
|
|||||||
volume_path = os.path.join(self.configuration.gpfs_mount_point_base,
|
volume_path = os.path.join(self.configuration.gpfs_mount_point_base,
|
||||||
snapshot['volume_name'])
|
snapshot['volume_name'])
|
||||||
self._create_gpfs_snap(src=volume_path, dest=snapshot_path)
|
self._create_gpfs_snap(src=volume_path, dest=snapshot_path)
|
||||||
|
self._gpfs_redirect(volume_path)
|
||||||
|
|
||||||
def delete_snapshot(self, snapshot):
|
def delete_snapshot(self, snapshot):
|
||||||
"""Deletes a GPFS snapshot."""
|
"""Deletes a GPFS snapshot."""
|
||||||
# A snapshot file is deleted as a part of delete_volume when
|
# Rename the deleted snapshot to indicate it no longer exists in
|
||||||
# all volumes derived from it are deleted.
|
# cinder db. Attempt to delete the snapshot. If the snapshot has
|
||||||
|
# clone children, the delete will fail silently. When volumes that
|
||||||
|
# are clone children are deleted in the future, the remaining ts
|
||||||
|
# snapshots will also be deleted.
|
||||||
|
snapshot_path = self.local_path(snapshot)
|
||||||
|
snapshot_ts_path = '%s.ts' % snapshot_path
|
||||||
|
os.rename(snapshot_path, snapshot_ts_path)
|
||||||
|
self._execute('rm', '-f', snapshot_ts_path,
|
||||||
|
check_exit_code=False, run_as_root=True)
|
||||||
|
|
||||||
def local_path(self, volume):
|
def local_path(self, volume):
|
||||||
return os.path.join(self.configuration.gpfs_mount_point_base,
|
return os.path.join(self.configuration.gpfs_mount_point_base,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user