Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[v23.2.x] [CORE-96]: admin/server fix set_log_level handling of overlapping expirations #18445

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions src/v/redpanda/admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
#include <limits>
#include <memory>
#include <numeric>
#include <ranges>
#include <stdexcept>
#include <system_error>
#include <type_traits>
Expand Down Expand Up @@ -622,16 +623,14 @@ 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(),
[](const auto& a, const auto& b) {
return a.second.expires < b.second.expires;
});

if (next != _log_level_resets.end()) {
_log_level_timer.arm(next->second.expires);
if (_log_level_resets.empty()) {
return;
}

auto reset_values = _log_level_resets | std::views::values;
auto& lvl_rst = *std::ranges::min_element(
reset_values, std::less<>{}, &level_reset::expires);
_log_level_timer.arm(lvl_rst.expires);
Comment on lines -625 to +633
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the original actually bugged? Seems like the motivating issue would have been isolated to v23.3+

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah you are right, i didn't notice that v23.2 has the correct comparator

}

void admin_server::log_level_timer_handler() {
Expand Down
28 changes: 28 additions & 0 deletions tests/rptest/tests/log_level_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
# the Business Source License, use of this software will be governed
# by the Apache License, Version 2.0

import time
import ducktape.errors
import requests.exceptions
import urllib.parse

from ducktape.mark import parametrize
from ducktape.utils.util import wait_until
from rptest.services.cluster import cluster
from rptest.tests.redpanda_test import RedpandaTest
Expand Down Expand Up @@ -94,6 +96,32 @@ def test_log_level_control(self):
backoff_sec=1,
err_msg="Never saw message")

@cluster(num_nodes=1)
@parametrize(loggers=("admin_api_server", "raft"))
@parametrize(loggers=("raft", "admin_api_server"))
def test_log_level_multiple_expiry(self, loggers=tuple[str, str]):
"""
Check that more than one logger can be in a modified level and be expired correctly
see https://redpandadata.atlassian.net/browse/CORE-96
"""
admin = Admin(self.redpanda)
node = self.redpanda.nodes[0]

first_logger, second_logger = loggers
# set two loggers to trace, expect that both of them expires in a timely fashion
with self.redpanda.monitor_log(node) as mon:
admin.set_log_level(first_logger, "trace", expires=10)
time.sleep(1)
admin.set_log_level(second_logger, "trace", expires=10)
mon.wait_until(f"Expiring log level for {{{first_logger}}}",
timeout_sec=15,
backoff_sec=1,
err_msg=f"Never saw Expiring for {first_logger}")
mon.wait_until(f"Expiring log level for {{{second_logger}}}",
timeout_sec=15,
backoff_sec=1,
err_msg=f"Never saw Expiring for {second_logger}")

@cluster(num_nodes=3)
def test_invalid_logger_name(self):
admin = Admin(self.redpanda)
Expand Down
Loading