From: Rishabh Dave Date: Sat, 29 Mar 2025 16:27:51 +0000 (+0530) Subject: mgr/vol: support clone operation on subvol v3 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=5d2b8a45020aa50e0acebfa06ea810c5707d151f;p=ceph-ci.git mgr/vol: support clone operation on subvol v3 Signed-off-by: Rishabh Dave --- diff --git a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py index 4d4a8dea66c..eadd6c32ded 100644 --- a/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py +++ b/src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py @@ -257,3 +257,28 @@ class SubvolumeV3(SubvolumeV2): MetadataManager.GLOBAL_META_KEY_STATE, SubvolumeStates.STATE_RETAINED.value) self.metadata_mgr.flush() + + # Following methods help clone operation - + + + def snapshot_data_path(self, snap_name): + snap_path = join(self.snapshot_path(snap_name), b'mnt') + + # v2 raises exception if the snapshot path do not exist so do the same + # to prevent any bugs due to difference in behaviour. + # + # not raising exception indeed leads to a bug: the volumes plugin fails + # when exception is not raised by this method when it is called by + # do_clone() method of async_cloner.py. this is made to happen by a + # test by deleting snapshot after running the snapshot clone command + # but before the clone operation actually begins. this is done by + # adding a delay using mgr/volumes/snapshot_clone_delay config option. + try: + self.fs.stat(snap_path) + except cephfs.Error as e: + if e.errno == errno.ENOENT: + raise VolumeException(-errno.ENOENT, + f'snapshot \'{snap_name}\' does not exist') + raise VolumeException(-e.args[0], e.args[1]) + + return snap_path