]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: 'versions' command to show running versions for daemons of all types
authorSage Weil <sage@redhat.com>
Thu, 20 Jul 2017 20:35:20 +0000 (16:35 -0400)
committerSage Weil <sage@redhat.com>
Fri, 21 Jul 2017 15:25:04 +0000 (11:25 -0400)
Easier!

Signed-off-by: Sage Weil <sage@redhat.com>
doc/release-notes.rst
src/mgr/ServiceMap.h
src/mon/MonCommands.h
src/mon/Monitor.cc

index 086f358c4136fe032dcd4a55b342f06f709d7b9d..3e3f80395e418fdfda9b03f7cceb1d4a516f54bb 100644 (file)
@@ -160,7 +160,8 @@ Major Changes from Kraken
     - The ``ceph -s`` or ``ceph status`` command has a fresh look.
     - ``ceph mgr metadata`` will dump metadata associated with each mgr
       daemon.
-    - ``ceph {osd,mds,mon,mgr} versions`` summarizes versions of running daemons.
+    - ``ceph versions`` or ``ceph {osd,mds,mon,mgr} versions``
+      summarize versions of running daemons.
     - ``ceph {osd,mds,mon,mgr} count-metadata <property>`` similarly
       tabulates any other daemon metadata visible via the ``ceph
       {osd,mds,mon,mgr} metadata`` commands.
@@ -317,6 +318,10 @@ Upgrade from Jewel or Kraken
 
 #. Do not create any new erasure-code pools while upgrading the monitors.
 
+#. You can monitor the progress of your upgrade at each stage with the
+   ``ceph versions`` command, which will tell you what ceph version is
+   running for each type of daemon.
+
 #. Set the ``noout`` flag for the duration of the upgrade. (Optional
    but recommended.)::
 
@@ -368,7 +373,7 @@ Upgrade from Jewel or Kraken
      # systemctl restart ceph-osd.target
 
    You can monitor the progress of the OSD upgrades with the new
-   ``ceph osd versions`` command.::
+   ``ceph versions`` or ``ceph osd versions`` command.::
 
      # ceph osd versions
      {
index 5137f9f84f26a8bec89bb428b78f26009a79f1b8..cd12133b87116a8226023243a522e0a03ae450f3 100644 (file)
@@ -51,6 +51,19 @@ struct ServiceMap {
         << " active";
       return ss.str();
     }
+
+    void count_metadata(const string& field,
+                       std::map<std::string,int> *out) const {
+      for (auto& p : daemons) {
+       auto q = p.second.metadata.find(field);
+       if (q == p.second.metadata.end()) {
+         (*out)["unknown"]++;
+       } else {
+         (*out)[q->second]++;
+       }
+      }
+    }
+
   };
 
   epoch_t epoch = 0;
index 7051056fd44470ddab351a1490dc99b9acb70b16..0aa418275af21793459d369b77f4047f908e61e1 100644 (file)
@@ -279,6 +279,10 @@ COMMAND("mon count-metadata name=property,type=CephString",
 COMMAND("mon versions",
        "check running versions of monitors",
        "mon", "r", "cli,rest")
+COMMAND("versions",
+       "check running versions of ceph daemons",
+       "mon", "r", "cli,rest")
+
 
 
 /*
index de7ec98960fb33e2868b459d37250f961daa7373..b62738fbd5232dc615c56f877e0440d63d6c03c6 100644 (file)
@@ -3564,6 +3564,65 @@ void Monitor::handle_command(MonOpRequestRef op)
     rdata.append(ds);
     rs = "";
     r = 0;
+  } else if (prefix == "versions") {
+    if (!f)
+      f.reset(Formatter::create("json-pretty"));
+    map<string,int> overall;
+    f->open_object_section("version");
+    map<string,int> mon, mgr, osd, mds;
+
+    count_metadata("ceph_version", &mon);
+    f->open_object_section("mon");
+    for (auto& p : mon) {
+      f->dump_int(p.first.c_str(), p.second);
+      overall[p.first] += p.second;
+    }
+    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;
+    }
+    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;
+    }
+    f->close_section();
+
+    mdsmon()->count_metadata("ceph_version", &mds);
+    f->open_object_section("mds");
+    for (auto& p : mon) {
+      f->dump_int(p.first.c_str(), p.second);
+      overall[p.first] += p.second;
+    }
+    f->close_section();
+
+    for (auto& p : mgrstatmon()->get_service_map().services) {
+      f->open_object_section(p.first.c_str());
+      map<string,int> m;
+      p.second.count_metadata("ceph_version", &m);
+      for (auto& q : m) {
+       f->dump_int(q.first.c_str(), q.second);
+       overall[q.first] += q.second;
+      }
+      f->close_section();
+    }
+
+    f->open_object_section("overall");
+    for (auto& p : overall) {
+      f->dump_int(p.first.c_str(), p.second);
+    }
+    f->close_section();
+    f->close_section();
+    f->flush(rdata);
+    rs = "";
+    r = 0;
   }
 
  out: