]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: remove empty list entries from ceph versions 48136/head
authorshreyanshjain7174 <ssanchet@redhat.com>
Mon, 19 Sep 2022 13:30:49 +0000 (08:30 -0500)
committershreyanshjain7174 <ssanchet@redhat.com>
Mon, 19 Sep 2022 13:32:23 +0000 (08:32 -0500)
In ceph versions command output, empty list gets printed for
mds. If there are no rgw/rbd-mirror daemon deployed, the
ceph versions command doesn't display version information
(empty list) for those daemons. Similar issue has been observed
for mgr and osd daemons. The ceph versions should only show
version information for daemons which are deployed in the cluster.

Fixes: https://tracker.ceph.com/issues/57585
Signed-off-by: shreyanshjain7174 <ssanchet@redhat.com>
src/mon/Monitor.cc

index 0846fa0a8f00bd771ebccf1496b7149970c2eea4..cc5a81982beb2c420874ebff77460637b0457454 100644 (file)
@@ -3940,29 +3940,35 @@ void Monitor::handle_command(MonOpRequestRef op)
     }
     f->close_section();
 
-    mgrmon()->count_metadata("ceph_version", &mgr);
-    f->open_object_section("mgr");
-    for (auto& p : mgr) {
-      f->dump_int(p.first.c_str(), p.second);
-      overall[p.first] += p.second;
+    if (!mgr.empty()) {
+      mgrmon()->count_metadata("ceph_version", &mgr);
+      f->open_object_section("mgr");
+      for (auto& p : mgr) {
+        f->dump_int(p.first.c_str(), p.second);
+        overall[p.first] += p.second;
+      }
+      f->close_section();
     }
-    f->close_section();
 
-    osdmon()->count_metadata("ceph_version", &osd);
-    f->open_object_section("osd");
-    for (auto& p : osd) {
-      f->dump_int(p.first.c_str(), p.second);
-      overall[p.first] += p.second;
+    if (!osd.empty()) {
+      osdmon()->count_metadata("ceph_version", &osd);
+      f->open_object_section("osd");
+      for (auto& p : osd) {
+        f->dump_int(p.first.c_str(), p.second);
+        overall[p.first] += p.second;
+      }
+      f->close_section();
     }
-    f->close_section();
 
-    mdsmon()->count_metadata("ceph_version", &mds);
-    f->open_object_section("mds");
-    for (auto& p : mds) {
-      f->dump_int(p.first.c_str(), p.second);
-      overall[p.first] += p.second;
+    if (!mds.empty()) {
+      mdsmon()->count_metadata("ceph_version", &mds);
+      f->open_object_section("mds");
+      for (auto& p : mds) {
+        f->dump_int(p.first.c_str(), p.second);
+        overall[p.first] += p.second;
+      }
+      f->close_section();
     }
-    f->close_section();
 
     for (auto& p : mgrstatmon()->get_service_map().services) {
       auto &service = p.first;