From: Sage Weil Date: Fri, 19 Nov 2021 00:04:48 +0000 (-0500) Subject: mon: fix quorum_age() regression X-Git-Tag: v17.1.0~351^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=68cfe785ccbc9ebd2a28492327142bb5878181a4;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 --- diff --git a/src/mon/Monitor.cc b/src/mon/Monitor.cc index be3d05623a1d..9cce1b510d74 100644 --- a/src/mon/Monitor.cc +++ b/src/mon/Monitor.cc @@ -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 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 4c9566b396a3..454daf63c6c7 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(); }