From 19a638398b66923fc2060a352e8956d6a18c34ad Mon Sep 17 00:00:00 2001 From: John Spray Date: Wed, 4 May 2022 10:58:07 +0100 Subject: [PATCH] cluster: fix disabling leader balancer at runtime Previously, the ss::repeat loop would keep running and eventually re-arm the timer when it ran out of work, if it was running while enable_leader_balancer was set to false. Fixes #4544 (cherry picked from commit 40636fa49823b8ae529320c31676342dcadf9ab1) --- src/v/cluster/scheduling/leader_balancer.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/v/cluster/scheduling/leader_balancer.cc b/src/v/cluster/scheduling/leader_balancer.cc index 33a2e7938adf..1ae49db890b2 100644 --- a/src/v/cluster/scheduling/leader_balancer.cc +++ b/src/v/cluster/scheduling/leader_balancer.cc @@ -156,6 +156,7 @@ void leader_balancer::trigger_balance() { vlog( clusterlog.info, "Cannot start rebalance until previous fiber exits"); _timer.arm(_idle_timeout()); + return; } if (!_enabled()) { @@ -187,6 +188,10 @@ void leader_balancer::trigger_balance() { } ss::future leader_balancer::balance() { + if (!_enabled()) { + co_return ss::stop_iteration::yes; + } + /* * GC the muted and last leader indices */