]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix quorum_age() regression 43698/head
authorSage Weil <sage@newdream.net>
Fri, 19 Nov 2021 00:04:48 +0000 (19:04 -0500)
committerCory Snyder <csnyder@iland.com>
Fri, 7 Jan 2022 10:24:48 +0000 (05:24 -0500)
We need to cast this to chrono::seconds or else it will overload the int
return type.

Partially reverts 1a9aab62b615830107ee28866630f043e1a01a35: the quorum_age()
users want seconds explicitly. The status caller reverts back to chrono
types so that it can be passed to timespan_str().

Fixes: 1a9aab62b615830107ee28866630f043e1a01a35
Signed-off-by: Sage Weil <sage@newdream.net>
(cherry picked from commit 68cfe785ccbc9ebd2a28492327142bb5878181a4)

src/mon/Monitor.cc
src/mon/Monitor.h

index dce5bb25b2cea4e10eb4de218fcc8feb8fba3314..70dd59773be17121c1763669035d9d0ab5a2c682 100644 (file)
@@ -3037,8 +3037,9 @@ void Monitor::get_cluster_status(stringstream &ss, Formatter *f,
       string spacing(maxlen - 3, ' ');
       const auto quorum_names = get_quorum_names();
       const auto mon_count = monmap->mon_info.size();
+      auto mnow = ceph::mono_clock::now();
       ss << "    mon: " << spacing << mon_count << " daemons, quorum "
-        << quorum_names << " (age " << quorum_age() << ")";
+        << quorum_names << " (age " << timespan_str(mnow - quorum_since) << ")";
       if (quorum_names.size() != mon_count) {
        std::list<std::string> out_of_q;
        for (size_t i = 0; i < monmap->ranks.size(); ++i) {
index 99762c35b96d540dfd30d5a52daa1c8b5d9d3b47..e16dc4a323a32770a6417372e3d7d7ab1b9892f3 100644 (file)
@@ -217,7 +217,8 @@ public:
   std::vector<DaemonHealthMetric> get_health_metrics();
 
   int quorum_age() const {
-    auto age = ceph::mono_clock::now() - quorum_since;
+    auto age = std::chrono::duration_cast<std::chrono::seconds>(
+      ceph::mono_clock::now() - quorum_since);
     return age.count();
   }