From: Jos Collin Date: Thu, 4 Apr 2024 11:28:36 +0000 (+0530) Subject: cephfs_mirror: update peer status for invalid metadata in remote snapshot X-Git-Tag: v20.0.0~1233^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=8055255c73f5eaadbe507999ff091cb269d72712;p=ceph.git cephfs_mirror: update peer status for invalid metadata in remote snapshot Fixes: https://tracker.ceph.com/issues/65317 Signed-off-by: Jos Collin --- diff --git a/src/tools/cephfs_mirror/PeerReplayer.cc b/src/tools/cephfs_mirror/PeerReplayer.cc index ce35b72ed0e9..b56ca9a2f1cc 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.cc +++ b/src/tools/cephfs_mirror/PeerReplayer.cc @@ -528,8 +528,9 @@ int PeerReplayer::build_snap_map(const std::string &dir_root, uint64_t snap_id; if (is_remote) { if (!info.nr_snap_metadata) { - derr << ": snap_path=" << snap_path << " has invalid metadata in remote snapshot" - << dendl; + std::string failed_reason = "snapshot '" + snap + "' has invalid metadata"; + derr << ": " << failed_reason << dendl; + m_snap_sync_stats.at(dir_root).last_failed_reason = failed_reason; rv = -EINVAL; } else { auto metadata = decode_snap_metadata(info.snap_metadata, info.nr_snap_metadata); @@ -1807,6 +1808,9 @@ void PeerReplayer::peer_status(Formatter *f) { f->open_object_section(dir_root); if (sync_stat.failed) { f->dump_string("state", "failed"); + if (sync_stat.last_failed_reason) { + f->dump_string("failure_reason", *sync_stat.last_failed_reason); + } } else if (!sync_stat.current_syncing_snap) { f->dump_string("state", "idle"); } else { diff --git a/src/tools/cephfs_mirror/PeerReplayer.h b/src/tools/cephfs_mirror/PeerReplayer.h index 6d04cf0cd838..933cb182635b 100644 --- a/src/tools/cephfs_mirror/PeerReplayer.h +++ b/src/tools/cephfs_mirror/PeerReplayer.h @@ -141,6 +141,7 @@ private: struct SnapSyncStat { uint64_t nr_failures = 0; // number of consecutive failures boost::optional last_failed; // lat failed timestamp + boost::optional last_failed_reason; bool failed = false; // hit upper cap for consecutive failures boost::optional> last_synced_snap; boost::optional> current_syncing_snap; @@ -177,6 +178,7 @@ private: sync_stat.nr_failures = 0; sync_stat.failed = false; sync_stat.last_failed = boost::none; + sync_stat.last_failed_reason = boost::none; } void _set_last_synced_snap(const std::string &dir_root, uint64_t snap_id,