Skip to content

Commit ea06d79

Browse files
committed
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 <[email protected]> (cherry picked from commit c318f80)
1 parent f9efe0b commit ea06d79

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/mon/MgrStatMonitor.cc

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,28 @@ static ostream& _prefix(std::ostream *_dout, Monitor &mon) {
5252
MgrStatMonitor::MgrStatMonitor(Monitor &mn, Paxos &p, const string& service_name)
5353
: PaxosService(mn, p, service_name)
5454
{
55+
g_conf().add_observer(this);
5556
}
5657

57-
MgrStatMonitor::~MgrStatMonitor() = default;
58+
MgrStatMonitor::~MgrStatMonitor()
59+
{
60+
g_conf().remove_observer(this);
61+
}
62+
63+
std::vector<std::string> MgrStatMonitor::get_tracked_keys() const noexcept
64+
{
65+
return {
66+
"enable_availability_tracking",
67+
};
68+
}
69+
70+
void MgrStatMonitor::handle_conf_change(
71+
const ConfigProxy& conf,
72+
const std::set<std::string>& changed)
73+
{
74+
// implement changes here
75+
dout(10) << __func__ << " enable_availability_tracking config option is changed." << dendl;
76+
}
5877

5978
void MgrStatMonitor::create_initial()
6079
{

src/mon/MgrStatMonitor.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88
#include "mon/PGMap.h"
99
#include "mgr/ServiceMap.h"
1010

11-
class MgrStatMonitor : public PaxosService {
11+
class MgrStatMonitor : public PaxosService,
12+
public md_config_obs_t {
1213
// live version
1314
version_t version = 0;
1415
PGMapDigest digest;
@@ -114,4 +115,9 @@ class MgrStatMonitor : public PaxosService {
114115
bool verbose) const {
115116
digest.dump_pool_stats_full(osdm, ss, f, verbose);
116117
}
118+
119+
// config observer
120+
std::vector<std::string> get_tracked_keys() const noexcept override;
121+
void handle_conf_change(const ConfigProxy& conf,
122+
const std::set <std::string> &changed) override;
117123
};

0 commit comments

Comments
 (0)