Skip to content

Commit

Permalink
admin/server: fix rearm_log_level_timer
Browse files Browse the repository at this point in the history
_log_level_resets is a map<str, level_reset>, we want to extract the
next expiring level_reset to rearm the _log_level_timer.

previously we would extract the min_element based on the key (the logger
name)

so this sequence of actions
set log-level kafka trace 10
set log-level raft trace 10

only kafka would be expired, because once expired the next run would
pick again kafka, see that there is no expiration, and not rearm the
timer.
  • Loading branch information
andijcr committed May 10, 2024
1 parent eb003fe commit bf6bc91
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src/v/redpanda/admin/server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -661,11 +661,17 @@ void admin_server::log_exception(
void admin_server::rearm_log_level_timer() {
_log_level_timer.cancel();

auto next = std::min_element(
_log_level_resets.begin(), _log_level_resets.end());
if (_log_level_resets.empty()) {
return;
}

if (next != _log_level_resets.end() && next->second.expires.has_value()) {
_log_level_timer.arm(next->second.expires.value());
auto reset_values = _log_level_resets | std::views::values;
auto& lvl_rst = *std::ranges::min_element(
reset_values, std::less<>{}, [](level_reset const& l) {
return l.expires.value_or(ss::timer<>::clock::time_point::max());
});
if (lvl_rst.expires.has_value()) {
_log_level_timer.arm(lvl_rst.expires.value());
}
}

Expand Down

0 comments on commit bf6bc91

Please sign in to comment.