]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/vol: for "clone status" handle case where path goes missing
authorRishabh Dave <ridave@redhat.com>
Wed, 2 Apr 2025 15:28:25 +0000 (20:58 +0530)
committerRishabh Dave <ridave@redhat.com>
Thu, 24 Apr 2025 13:02:43 +0000 (18:32 +0530)
If source and/or destination path of the cloning operation goes missing
during it's ongoing or just before it becomes ongoing, "ceph fs clone
status" command can fail. Account for and handle such cases gracefully.

Fixes: https://tracker.ceph.com/issues/71019
Signed-off-by: Rishabh Dave <ridave@redhat.com>
src/pybind/mgr/volumes/fs/stats_util.py
src/pybind/mgr/volumes/fs/volume.py

index 858aed3f5f78bbadae9353a00ca4ed03c5ef7a63..667a5ee29bf17cdb3a787eac027104ba82f7b33c 100644 (file)
@@ -65,11 +65,31 @@ def get_percent_copied(src_path, dst_path, fs_handle):
 
 def get_stats(src_path, dst_path, fs_handle):
     rentries = 'ceph.dir.rentries'
-    rentries_t = int(fs_handle.getxattr(src_path, rentries))
-    rentries_c = int(fs_handle.getxattr(dst_path, rentries))
-
-    size_t, size_c, percent = get_amount_copied(src_path, dst_path, fs_handle)
-
+    # set it to true when either src_path or dst_path has gone missing.
+    either_path_gone_missing = False
+
+    try:
+        rentries_t = int(fs_handle.getxattr(src_path, rentries))
+    except ObjectNotFound:
+        either_path_gone_missing = True
+        log.info(f'get_stats(): source path "{src_path}" went missing, '
+                  'couldn\'t run getxattr on it')
+
+    try:
+        rentries_c = int(fs_handle.getxattr(dst_path, rentries))
+    except ObjectNotFound:
+        either_path_gone_missing = True
+        log.info(f'get_stats(): destination path "{dst_path}" went missing, '
+                  'couldn\'t run getxattr on it')
+
+    if either_path_gone_missing:
+        return {}
+
+    retval = get_amount_copied(src_path, dst_path, fs_handle)
+    if not retval:
+        return {}
+
+    size_t, size_c, percent = retval
     return {
         'percentage cloned': percent,
         'amount cloned': get_size_ratio_str(size_c, size_t),
index 4fa62201fc58e841e078a6ae907b187342822541..860203dd7ffd57a657c5e1a8d8c353bd3bce72b0 100644 (file)
@@ -1035,7 +1035,8 @@ class VolumeClient(CephfsClient["Module"]):
             return None
 
         stats = get_stats(src_path, dst_path, vol_handle)
-        stats['percentage cloned'] = str(stats['percentage cloned']) + '%'
+        if stats:
+            stats['percentage cloned'] = str(stats['percentage cloned']) + '%'
         return stats
 
     def _get_clone_status(self, vol_handle, group, subvol):