From: Rishabh Dave Date: Wed, 2 Apr 2025 15:28:25 +0000 (+0530) Subject: mgr/vol: for "clone status" handle case where path goes missing X-Git-Tag: v20.1.0~29^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=223d5c17566c06df7060b89b49e6c55b9a1e88c5;p=ceph.git mgr/vol: for "clone status" handle case where path goes missing 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 (cherry picked from commit ad38967a5b9b498c4e64ca276158a4d7b7eb8b06) --- diff --git a/src/pybind/mgr/volumes/fs/stats_util.py b/src/pybind/mgr/volumes/fs/stats_util.py index 858aed3f5f7..667a5ee29bf 100644 --- a/src/pybind/mgr/volumes/fs/stats_util.py +++ b/src/pybind/mgr/volumes/fs/stats_util.py @@ -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), diff --git a/src/pybind/mgr/volumes/fs/volume.py b/src/pybind/mgr/volumes/fs/volume.py index 4fa62201fc5..860203dd7ff 100644 --- a/src/pybind/mgr/volumes/fs/volume.py +++ b/src/pybind/mgr/volumes/fs/volume.py @@ -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):