]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/vol: handle case where path goes missing for a clone
authorRishabh Dave <ridave@redhat.com>
Wed, 2 Apr 2025 15:31:31 +0000 (21:01 +0530)
committerRishabh Dave <ridave@redhat.com>
Sun, 4 May 2025 13:31:42 +0000 (19:01 +0530)
A thread is spawned to get the value of a certain extended attribute to
generate the progress statistics for the ongoing clone operations. In
case source and/or destination path for a clone operation goes missing,
this thread crashes. Instead of crashing, handle this case gracefully.

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

index 667a5ee29bf17cdb3a787eac027104ba82f7b33c..683ffc2df85e7a95554358dbecac9ecc546deffc 100644 (file)
@@ -45,8 +45,19 @@ def get_num_ratio_str(num1, num2):
 def get_amount_copied(src_path, dst_path, fs_handle):
     rbytes = 'ceph.dir.rbytes'
 
-    size_t = int(fs_handle.getxattr(src_path, rbytes))
-    size_c = int(fs_handle.getxattr(dst_path, rbytes))
+    try:
+        size_t = int(fs_handle.getxattr(src_path, rbytes))
+    except ObjectNotFound:
+        log.info(f'get_amount_copied(): source path "{src_path}" went missing, '
+                  'couldn\'t run getxattr on it')
+        return
+
+    try:
+        size_c = int(fs_handle.getxattr(dst_path, rbytes))
+    except ObjectNotFound:
+        log.info(f'get_amount_copied(): destination path "{dst_path}" went '
+                  'missing, couldn\'t run getxattr on it')
+        return
 
     percent: Optional[float]
     if size_t == 0 or size_c == 0:
@@ -59,8 +70,12 @@ def get_amount_copied(src_path, dst_path, fs_handle):
 
 
 def get_percent_copied(src_path, dst_path, fs_handle):
-    _, _, percent = get_amount_copied(src_path, dst_path, fs_handle)
-    return percent
+    retval = get_amount_copied(src_path, dst_path, fs_handle)
+    if not retval:
+        return retval
+    else:
+        _, _, percent = retval
+        return percent
 
 
 def get_stats(src_path, dst_path, fs_handle):
@@ -294,6 +309,8 @@ class CloneProgressReporter:
                     fs_handle:
                 percent = get_percent_copied(clone.src_path, clone.dst_path,
                                              fs_handle)
+                if not percent:
+                    continue
                 if clone in clones[:total_ongoing_clones]:
                     sum_percent_ongoing += percent
                 if show_onpen_bar: