]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mon: fix quorum_age() regression 44018/head
authorSage Weil <sage@newdream.net>
Fri, 19 Nov 2021 00:04:48 +0000 (19:04 -0500)
committerSage Weil <sage@newdream.net>
Fri, 19 Nov 2021 15:28:20 +0000 (10:28 -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>
src/mon/Monitor.cc
src/mon/Monitor.h

index be3d05623a1d892925cb3b8d3f72c36e80cbe5c0..9cce1b510d7493cc837039bff31bca1a329f32a0 100644 (file)
@@ -3056,8 +3056,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 4c9566b396a31ff6a6b175e0b21ca7dce8c83a1d..454daf63c6c7583128633ad8aa511353c98b4e94 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();
   }