]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
src/mon/ConnectionTracker.cc: fix dump
authorKamoltat <ksirivad@redhat.com>
Tue, 30 Apr 2024 02:18:58 +0000 (02:18 +0000)
committerKamoltat <ksirivad@redhat.com>
Wed, 17 Jul 2024 22:22:53 +0000 (22:22 +0000)
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>
src/mon/ConnectionTracker.cc

index c87d614f6420fcfd9e4d63cecdab95f20eff58a2..52bfd02af817a74ec7fa0d9570076a9d1f5b278c 100644 (file)
@@ -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
 }