From: shreyanshjain7174 Date: Mon, 19 Sep 2022 13:30:49 +0000 (-0500) Subject: mon: remove empty list entries from ceph versions X-Git-Tag: v18.1.0~720^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=d3cca1d5ae692f332f5d3ed94ca1cec8e1ac0a8a;p=ceph.git mon: remove empty list entries from ceph versions 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 --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 0846fa0a8f00..cc5a81982beb 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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;