From ea06d797bc0923cb79a76803586d61e85a8738d3 Mon Sep 17 00:00:00 2001 From: Shraddha Agrawal Date: Thu, 22 May 2025 14:46:50 +0530 Subject: [PATCH] MgrStatMonitor: add config observer This commit adds a config observer to MgrStatMonitor so we can track when a user enables/disables enable_availability_tracking config option. The time difference between disabling and then enabling the config option will be used to offset the uptime and/or downtime from the availability score feature. Fixes: https://tracker.ceph.com/issues/71494 Signed-off-by: Shraddha Agrawal (cherry picked from commit c318f80ee2eeefbba9865f07026e18c313cba558) --- src/mon/MgrStatMonitor.cc | 21 ++++++++++++++++++++- src/mon/MgrStatMonitor.h | 8 +++++++- 2 files changed, 27 insertions(+), 2 deletions(-) diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index 52121a63c05d3..da31318b44191 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -52,9 +52,28 @@ static ostream& _prefix(std::ostream *_dout, Monitor &mon) { MgrStatMonitor::MgrStatMonitor(Monitor &mn, Paxos &p, const string& service_name) : PaxosService(mn, p, service_name) { + g_conf().add_observer(this); } -MgrStatMonitor::~MgrStatMonitor() = default; +MgrStatMonitor::~MgrStatMonitor() +{ + g_conf().remove_observer(this); +} + +std::vector MgrStatMonitor::get_tracked_keys() const noexcept +{ + return { + "enable_availability_tracking", + }; +} + +void MgrStatMonitor::handle_conf_change( + const ConfigProxy& conf, + const std::set& changed) +{ + // implement changes here + dout(10) << __func__ << " enable_availability_tracking config option is changed." << dendl; +} void MgrStatMonitor::create_initial() { diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index a50a4da083a2c..c02cbc4976b5d 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -8,7 +8,8 @@ #include "mon/PGMap.h" #include "mgr/ServiceMap.h" -class MgrStatMonitor : public PaxosService { + class MgrStatMonitor : public PaxosService, + public md_config_obs_t { // live version version_t version = 0; PGMapDigest digest; @@ -114,4 +115,9 @@ public: bool verbose) const { digest.dump_pool_stats_full(osdm, ss, f, verbose); } + + // config observer + std::vector get_tracked_keys() const noexcept override; + void handle_conf_change(const ConfigProxy& conf, + const std::set &changed) override; }; -- 2.39.5