From: Shraddha Agrawal Date: Thu, 26 Jun 2025 12:27:45 +0000 (+0530) Subject: mon/MgrStatMonitor.cc: cleanup handle_conf_change X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=950d911b4b28ffaffc2d63cfc15d4edabce2b533;p=ceph.git mon/MgrStatMonitor.cc: cleanup handle_conf_change Prior to this change, we were using a flag value, `reset_availability_last_uptime_downtime_val` to record the timestamp to which the last_uptime and last_downtime should be updated to. This was originally done so to avoid the values being overwritten by a paxos update. Now, instead of using an intermediate value, we are immediately clearing the last_uptime and last_downtime values in pending_pool_availability object. Since we are updating the values in the pending object, we will not lost this information due to an incoming paxos update. Fixes: https://tracker.ceph.com/issues/71857 Signed-off-by: Shraddha Agrawal --- diff --git a/src/mon/MgrStatMonitor.cc b/src/mon/MgrStatMonitor.cc index 4d85a260a8261..9bcee5b77d0ff 100644 --- a/src/mon/MgrStatMonitor.cc +++ b/src/mon/MgrStatMonitor.cc @@ -80,12 +80,16 @@ void MgrStatMonitor::handle_conf_change( << dendl; // if fetaure is toggled from off to on, - // store the new value of last_uptime and last_downtime - // (to be updated in calc_pool_availability) + // reset last_uptime and last_downtime across all pools if (newval > oldval) { - reset_availability_last_uptime_downtime_val = ceph_clock_now(); - dout(10) << __func__ << " reset_availability_last_uptime_downtime_val " - << reset_availability_last_uptime_downtime_val << dendl; + utime_t now = ceph_clock_now(); + for (const auto& i : pending_pool_availability) { + const auto& poolid = i.first; + pending_pool_availability[poolid].last_downtime = now; + pending_pool_availability[poolid].last_uptime = now; + } + dout(20) << __func__ << " reset last_uptime and last_downtime to " + << now << dendl; } enable_availability_tracking = newval; } @@ -195,18 +199,8 @@ void MgrStatMonitor::calc_pool_availability() } } - // if reset_availability_last_uptime_downtime_val is not utime_t(1, 2), - // update last_uptime and last_downtime for all pools to the - // recorded values - if (reset_availability_last_uptime_downtime_val.has_value()) { - dout(20) << fmt::format("{}: Pool {} reset last_uptime and last_downtime to {}", - __func__, poolid, reset_availability_last_uptime_downtime_val.value()) << dendl; - avail.last_downtime = reset_availability_last_uptime_downtime_val.value(); - avail.last_uptime = reset_availability_last_uptime_downtime_val.value(); - } } pending_pool_availability = pool_availability; - reset_availability_last_uptime_downtime_val.reset(); } void MgrStatMonitor::update_from_paxos(bool *need_bootstrap) diff --git a/src/mon/MgrStatMonitor.h b/src/mon/MgrStatMonitor.h index 66a184090e9d5..ef06087d24ca6 100644 --- a/src/mon/MgrStatMonitor.h +++ b/src/mon/MgrStatMonitor.h @@ -56,7 +56,6 @@ public: void calc_pool_availability(); bool enable_availability_tracking = g_conf().get_val("enable_availability_tracking"); ///< tracking availability score feature - std::optional reset_availability_last_uptime_downtime_val; void clear_pool_availability(int64_t poolid);