]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/vol: support clone operation on subvol v3
authorRishabh Dave <ridave@redhat.com>
Sat, 29 Mar 2025 16:27:51 +0000 (21:57 +0530)
committerRishabh Dave <ridave@redhat.com>
Wed, 3 Dec 2025 07:51:08 +0000 (13:21 +0530)
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/pybind/mgr/volumes/fs/operations/versions/subvolume_v3.py

index 4d4a8dea66cd6286921e3dea827c45341f1b4bdc..eadd6c32ded35344dd425f0685acb3ac854c8007 100644 (file)
@@ -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