Skip to content

Commit 8055255

Browse files
committed
cephfs_mirror: update peer status for invalid metadata in remote snapshot
Fixes: https://tracker.ceph.com/issues/65317 Signed-off-by: Jos Collin <[email protected]>
1 parent 530a260 commit 8055255

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/tools/cephfs_mirror/PeerReplayer.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -528,8 +528,9 @@ int PeerReplayer::build_snap_map(const std::string &dir_root,
528528
uint64_t snap_id;
529529
if (is_remote) {
530530
if (!info.nr_snap_metadata) {
531-
derr << ": snap_path=" << snap_path << " has invalid metadata in remote snapshot"
532-
<< dendl;
531+
std::string failed_reason = "snapshot '" + snap + "' has invalid metadata";
532+
derr << ": " << failed_reason << dendl;
533+
m_snap_sync_stats.at(dir_root).last_failed_reason = failed_reason;
533534
rv = -EINVAL;
534535
} else {
535536
auto metadata = decode_snap_metadata(info.snap_metadata, info.nr_snap_metadata);
@@ -1807,6 +1808,9 @@ void PeerReplayer::peer_status(Formatter *f) {
18071808
f->open_object_section(dir_root);
18081809
if (sync_stat.failed) {
18091810
f->dump_string("state", "failed");
1811+
if (sync_stat.last_failed_reason) {
1812+
f->dump_string("failure_reason", *sync_stat.last_failed_reason);
1813+
}
18101814
} else if (!sync_stat.current_syncing_snap) {
18111815
f->dump_string("state", "idle");
18121816
} else {

src/tools/cephfs_mirror/PeerReplayer.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class PeerReplayer {
141141
struct SnapSyncStat {
142142
uint64_t nr_failures = 0; // number of consecutive failures
143143
boost::optional<monotime> last_failed; // lat failed timestamp
144+
boost::optional<std::string> last_failed_reason;
144145
bool failed = false; // hit upper cap for consecutive failures
145146
boost::optional<std::pair<uint64_t, std::string>> last_synced_snap;
146147
boost::optional<std::pair<uint64_t, std::string>> current_syncing_snap;
@@ -177,6 +178,7 @@ class PeerReplayer {
177178
sync_stat.nr_failures = 0;
178179
sync_stat.failed = false;
179180
sync_stat.last_failed = boost::none;
181+
sync_stat.last_failed_reason = boost::none;
180182
}
181183

182184
void _set_last_synced_snap(const std::string &dir_root, uint64_t snap_id,

0 commit comments

Comments
 (0)