From: Sage Weil Date: Fri, 19 Nov 2021 00:04:48 +0000 (-0500) Subject: mon: fix quorum_age() regression X-Git-Tag: v16.2.8~88^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F43698%2Fhead;p=ceph.git mon: fix quorum_age() regression 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 (cherry picked from commit 68cfe785ccbc9ebd2a28492327142bb5878181a4) --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index dce5bb25b2ce..70dd59773be1 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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 out_of_q; for (size_t i = 0; i < monmap->ranks.size(); ++i) { diff --git a/src/mon/Monitor.h b/src/mon/Monitor.h index 99762c35b96d..e16dc4a323a3 100644 --- a/src/mon/Monitor.h +++ b/src/mon/Monitor.h @@ -217,7 +217,8 @@ public: std::vector get_health_metrics(); int quorum_age() const { - auto age = ceph::mono_clock::now() - quorum_since; + auto age = std::chrono::duration_cast( + ceph::mono_clock::now() - quorum_since); return age.count(); }