mirror of
https://github.com/ceph/ceph
synced 2025-02-21 09:57:26 +00:00
src/mon/ConnectionTracker.cc: fix dump
Problem: Currently, the ConnectionTracker::dump() will dump a duplicate key which is not ideal when you want to write a test that converts the dump into a JSON since JSON objects are key-value pairs where each key must be unique. Solution: Use open_array_section and convert `peer_scores` and `reports` into an array instead. Fixes: https://tracker.ceph.com/issues/65695 Signed-off-by: Kamoltat <ksirivad@redhat.com>
This commit is contained in:
parent
103cd8e78b
commit
c05d4e2716
@ -325,13 +325,13 @@ void ConnectionReport::dump(ceph::Formatter *f) const
|
||||
f->dump_int("rank", rank);
|
||||
f->dump_int("epoch", epoch);
|
||||
f->dump_int("version", epoch_version);
|
||||
f->open_object_section("peer_scores");
|
||||
f->open_array_section("peer_scores");
|
||||
for (auto i : history) {
|
||||
f->open_object_section("peer");
|
||||
f->dump_int("peer_rank", i.first);
|
||||
f->dump_float("peer_score", i.second);
|
||||
f->dump_bool("peer_alive", current.find(i.first)->second);
|
||||
f->close_section();
|
||||
f->close_section(); // peer
|
||||
}
|
||||
f->close_section(); // peer scores
|
||||
}
|
||||
@ -354,11 +354,11 @@ void ConnectionTracker::dump(ceph::Formatter *f) const
|
||||
f->dump_int("version", version);
|
||||
f->dump_float("half_life", half_life);
|
||||
f->dump_int("persist_interval", persist_interval);
|
||||
f->open_object_section("reports");
|
||||
f->open_array_section("reports");
|
||||
for (const auto& i : peer_reports) {
|
||||
f->open_object_section("report");
|
||||
i.second.dump(f);
|
||||
f->close_section();
|
||||
f->close_section(); // report
|
||||
}
|
||||
f->close_section(); // reports
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user