]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
src/mon/ConnectionTracker.cc: && HealthMonitor.cc Improve logging
authorKamoltat Sirivadhna <ksirivad@redhat.com>
Mon, 14 Jul 2025 18:46:02 +0000 (18:46 +0000)
committerKamoltat Sirivadhna <ksirivad@redhat.com>
Tue, 7 Oct 2025 19:53:00 +0000 (19:53 +0000)
Improve logging for Netsplit pairs and
other variables in HealthMonitor::check_netsplit

Fixes: https://tracker.ceph.com/issues/71344
Signed-off-by: Kamoltat Sirivadhna <ksirivad@redhat.com>
src/mon/ConnectionTracker.cc
src/mon/HealthMonitor.cc

index 66c92865af124e77cd3996e28ffe793222127459..86dabceb2113ca7cedc60b7cf260d61f9868e3b6 100644 (file)
@@ -426,11 +426,14 @@ std::set<std::pair<unsigned, unsigned>> ConnectionTracker::get_netsplit(
     }
     // For debugging purposes:
     if (cct->_conf->subsys.should_gather(ceph_subsys_mon, 30)) {
-      ldout(cct, 30) << "Netsplit pairs: " << dendl;
+      ldout(cct, 30) << "Netsplit pairs: {";
+      bool first = true;
       for (const auto& nsp_pair : nsp_pairs) {
-        ldout(cct, 30) << "(" << nsp_pair.first << ", "
-          << nsp_pair.second << ") " << dendl;
+        if (!first) *_dout << ", ";
+        first = false;
+        *_dout << "(" << nsp_pair.first << ", " << nsp_pair.second << ")";
       }
+      *_dout << "}" << dendl;
     }
     return nsp_pairs;
 }
index de8da7b524e552467a3a920890a1a43aade48d38..a8d33d241be27eaf9b71274b81a09a37f4a7e6f3 100644 (file)
@@ -1241,30 +1241,38 @@ void HealthMonitor::check_netsplit(health_check_map_t *checks, std::set<std::str
     }
     *_dout << "}" << dendl;
 
-    dout(30) << "mon_loc_map: " << dendl;
+    dout(30) << "mon_loc_map: { ";
+    bool outer_first = true;
     for (const auto& mon_pair : mon_loc_map) {
-      dout(30) << mon_pair.first << ": {";
-      bool first = true;
+      if (!outer_first) *_dout << ", ";
+      outer_first = false;
+      *_dout << mon_pair.first << ": {";
+      bool inner_first = true;
       for (const auto& loc_pair : mon_pair.second) {
-        if (!first) *_dout << ", ";
-        first = false;
+        if (!inner_first) *_dout << ", ";
+        inner_first = false;
         *_dout << loc_pair.first << ": " << loc_pair.second;
       }
-      *_dout << "}" << dendl;
+      *_dout << "}";
     }
+    *_dout << " }" << dendl;
 
 
-    dout(30) << "location_to_mons: " << dendl;
+    dout(30) << "location_to_mons: {";
+    bool outer_first = true;
     for (const auto& loc_pair : location_to_mons) {
-      dout(30) << loc_pair.first << ": {";
-      bool first = true;
+      if (!outer_first) *_dout << ", ";
+      outer_first = false;
+      *_dout << loc_pair.first << ": {";
+      bool inner_first = true;
       for (const auto& monitor : loc_pair.second) {
-        if (!first) *_dout << ", ";
-        first = false;
+        if (!inner_first) *_dout << ", ";
+        inner_first = false;
         *_dout << monitor;
       }
-      *_dout << "}" << dendl;
+      *_dout << "}";
     }
+    *_dout << " }" << dendl;
 
     dout(30) << "detected_location_netsplits: {";
     bool first = true;