From: Prashant D Date: Thu, 25 May 2023 22:09:02 +0000 (-0400) Subject: mon: Fix ceph versions command X-Git-Tag: v17.2.7~204^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F52161%2Fhead;p=ceph.git mon: Fix ceph versions command The commit-id d3cca1d has introduced a bug where mgr/osd/mds version information goes missing during the cluster upgrade. Collect version information before checking the emptiness of the map. Fixes: https://tracker.ceph.com/issues/61453 Signed-off-by: Prashant D (cherry picked from commit 3fbebe315f25a4d1ce8cb460710ba6da23dc40f4) --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index 3325fbd5cd4..ca63b96d06e 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -3946,28 +3946,34 @@ 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()) { + 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()) { + 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()) { + 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;