From 147979a4e2f4a9a6dfd0a35338a4371a73419618 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Thu, 18 Nov 2021 19:04:48 -0500 Subject: [PATCH] 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) --- src/mon/Monitor.cc | 3 ++- src/mon/Monitor.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) 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(); } -- 2.47.3