From 80a42122a023df2e716738fd06bef2d2a49dce8f Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 20 Jul 2017 16:35:20 -0400 Subject: [PATCH] mon: 'versions' command to show running versions for daemons of all types Easier! Signed-off-by: Sage Weil --- doc/release-notes.rst | 9 +++++-- src/mgr/ServiceMap.h | 13 ++++++++++ src/mon/MonCommands.h | 4 +++ src/mon/Monitor.cc | 59 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 83 insertions(+), 2 deletions(-) diff --git a/doc/release-notes.rst b/doc/release-notes.rst index 086f358c4136..3e3f80395e41 100644 --- a/doc/release-notes.rst +++ b/doc/release-notes.rst @@ -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 `` 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 { diff --git a/src/mgr/ServiceMap.h b/src/mgr/ServiceMap.h index 5137f9f84f26..cd12133b8711 100644 --- a/src/mgr/ServiceMap.h +++ b/src/mgr/ServiceMap.h @@ -51,6 +51,19 @@ struct ServiceMap { << " active"; return ss.str(); } + + void count_metadata(const string& field, + std::map *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; diff --git a/src/mon/MonCommands.h b/src/mon/MonCommands.h index 7051056fd444..0aa418275af2 100644 --- a/src/mon/MonCommands.h +++ b/src/mon/MonCommands.h @@ -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") + /* diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index de7ec98960fb..b62738fbd523 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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 overall; + f->open_object_section("version"); + map 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 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: -- 2.47.3