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),
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):