From f6d85aad99cfcbd3fc71ebd73e4fac26326e28f2 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Thu, 23 Jul 2026 17:06:46 +0530 Subject: [PATCH] cephfs_mirror: format sync timestamps as ISO-8601 local time Show sync_time_stamp and metrics_updated_at as human-readable local timestamps in peer_status and mgr status. Keep epoch in omap and counter dump. Fixes: https://tracker.ceph.com/issues/76506 Signed-off-by: Kotresh HR --- src/pybind/mgr/mirroring/fs/metrics/format.py | 11 +++++++++-- src/tools/cephfs_mirror/PeerReplayer.cc | 6 ++---- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/pybind/mgr/mirroring/fs/metrics/format.py b/src/pybind/mgr/mirroring/fs/metrics/format.py index 943eeb14e2c4..6ef0b8089f8f 100644 --- a/src/pybind/mgr/mirroring/fs/metrics/format.py +++ b/src/pybind/mgr/mirroring/fs/metrics/format.py @@ -1,3 +1,6 @@ +from ..checkpoint import format_epoch_timestamp + + def default_sync_stat_metrics(): return { 'state': 'idle', @@ -134,8 +137,8 @@ def format_and_order_sync_stat_for_display(stat, policy=None, dir_path=None, if isinstance(sync_bytes, (int, float)): snap['sync_bytes'] = _format_bytes(sync_bytes) sync_time_stamp = snap.get('sync_time_stamp') - if isinstance(sync_time_stamp, (int, float)): - snap['sync_time_stamp'] = f'{sync_time_stamp:.6f}s' + if isinstance(sync_time_stamp, (int, float, str)): + snap['sync_time_stamp'] = format_epoch_timestamp(sync_time_stamp) out['last_synced_snap'] = _order_dict( snap, ('id', 'name', 'crawl_duration', 'datasync_queue_wait_duration', 'sync_duration', @@ -146,6 +149,10 @@ def format_and_order_sync_stat_for_display(stat, policy=None, dir_path=None, out['current_syncing_snap'] = _order_current_syncing_snap( current_syncing_snap) + metrics_updated_at = out.get('metrics_updated_at') + if isinstance(metrics_updated_at, (int, float, str)): + out['metrics_updated_at'] = format_epoch_timestamp(metrics_updated_at) + out.pop('_instance_id', None) return _order_dict( diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index 09543a53a01f..50497cf3535a 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -3816,10 +3816,8 @@ void PeerReplayer::dump_sync_stat(Formatter *f, const SnapSyncStat &sync_stat) { f->dump_string("sync_duration", format_time(*sync_stat.last_sync_duration)); } if (!sync_stat.last_synced.is_zero()) { - std::ostringstream os; - os << std::fixed << std::setprecision(6) - << static_cast(sync_stat.last_synced); - f->dump_string("sync_time_stamp", os.str() + "s"); + // ISO-8601 local time with offset (matches utime_t::localtime / mgr format) + f->dump_string("sync_time_stamp", stringify(sync_stat.last_synced)); } if (sync_stat.last_sync_bytes) { f->dump_string("sync_bytes", format_bytes(*sync_stat.last_sync_bytes)); -- 2.47.3