Skip to content

Commit 359277b

Browse files
mgr/vol: handle case where path goes missing for a clone
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 <[email protected]>
1 parent ad38967 commit 359277b

File tree

1 file changed

+21
-4
lines changed

1 file changed

+21
-4
lines changed

src/pybind/mgr/volumes/fs/stats_util.py

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,19 @@ def get_num_ratio_str(num1, num2):
4545
def get_amount_copied(src_path, dst_path, fs_handle):
4646
rbytes = 'ceph.dir.rbytes'
4747

48-
size_t = int(fs_handle.getxattr(src_path, rbytes))
49-
size_c = int(fs_handle.getxattr(dst_path, rbytes))
48+
try:
49+
size_t = int(fs_handle.getxattr(src_path, rbytes))
50+
except ObjectNotFound:
51+
log.info(f'get_amount_copied(): source path "{src_path}" went missing, '
52+
'couldn\'t run getxattr on it')
53+
return
54+
55+
try:
56+
size_c = int(fs_handle.getxattr(dst_path, rbytes))
57+
except ObjectNotFound:
58+
log.info(f'get_amount_copied(): destination path "{dst_path}" went '
59+
'missing, couldn\'t run getxattr on it')
60+
return
5061

5162
percent: Optional[float]
5263
if size_t == 0 or size_c == 0:
@@ -59,8 +70,12 @@ def get_amount_copied(src_path, dst_path, fs_handle):
5970

6071

6172
def get_percent_copied(src_path, dst_path, fs_handle):
62-
_, _, percent = get_amount_copied(src_path, dst_path, fs_handle)
63-
return percent
73+
retval = get_amount_copied(src_path, dst_path, fs_handle)
74+
if not retval:
75+
return retval
76+
else:
77+
_, _, percent = retval
78+
return percent
6479

6580

6681
def get_stats(src_path, dst_path, fs_handle):
@@ -294,6 +309,8 @@ def _update_progress_bars(self):
294309
fs_handle:
295310
percent = get_percent_copied(clone.src_path, clone.dst_path,
296311
fs_handle)
312+
if not percent:
313+
continue
297314
if clone in clones[:total_ongoing_clones]:
298315
sum_percent_ongoing += percent
299316
if show_onpen_bar:

0 commit comments

Comments
 (0)