]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
MgrStatMonitor: add config observer
authorShraddha Agrawal <shraddha.agrawal000@gmail.com>
Thu, 22 May 2025 09:16:50 +0000 (14:46 +0530)
committerShraddha Agrawal <shraddha.agrawal000@gmail.com>
Thu, 12 Jun 2025 10:49:50 +0000 (16:19 +0530)
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 <shraddhaag@ibm.com>
src/mon/MgrStatMonitor.cc
src/mon/MgrStatMonitor.h

index 52121a63c05d37652fc4d6f6ce46057aac177ef6..da31318b44191f1577e1c7a91a569a439fc7273c 100644 (file)
@@ -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<std::string> MgrStatMonitor::get_tracked_keys() const noexcept
+{
+  return {
+    "enable_availability_tracking",
+  };
+}
+
+void MgrStatMonitor::handle_conf_change(
+  const ConfigProxy& conf,
+  const std::set<std::string>& changed)
+{
+  // implement changes here 
+  dout(10) << __func__ << " enable_availability_tracking config option is changed." << dendl;
+}
 
 void MgrStatMonitor::create_initial()
 {
index a50a4da083a2ca7dbe0fb7974a3b0e3e1621ced2..c02cbc4976b5dd7ce8a8c1034f2be3d62f8493b5 100644 (file)
@@ -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<std::string> get_tracked_keys() const noexcept override;
+  void handle_conf_change(const ConfigProxy& conf,
+                          const std::set <std::string> &changed) override;
 };