]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: Fix ceph versions command 52161/head
authorPrashant D <pdhange@redhat.com>
Thu, 25 May 2023 22:09:02 +0000 (18:09 -0400)
committerPrashant D <pdhange@redhat.com>
Thu, 22 Jun 2023 19:17:53 +0000 (15:17 -0400)
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 <pdhange@redhat.com>
(cherry picked from commit 3fbebe315f25a4d1ce8cb460710ba6da23dc40f4)

src/mon/Monitor.cc

index 3325fbd5cd446c06bd9976b382d4d23a8c70306c..ca63b96d06e62713ec8d41873537ebdea5233505 100644 (file)
@@ -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;