]> git.apps.os.sepia.ceph.com Git - ceph.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>
Fri, 18 Jul 2025 05:13:04 +0000 (05:13 +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 513d823011928de0461eef2a74a80db24c6a3acf..5ef3903dbb1a188e552fdf1b37b3ebddcb8f43ca 100644 (file)
@@ -425,11 +425,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 007b2e7a6f2315ed1ef364881182c4c35f88afd6..85b199958fba1bfedd90e7d674cb0f92dd70d61c 100644 (file)
@@ -1203,30 +1203,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;