Skip to content

Commit

Permalink
ignore maintenance
Browse files Browse the repository at this point in the history
  • Loading branch information
rystsov committed Sep 27, 2023
1 parent 0cb37cc commit c9f3401
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 27 deletions.
4 changes: 1 addition & 3 deletions src/v/cluster/partition_balancer_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -381,9 +381,7 @@ ss::future<> partition_balancer_backend::do_tick() {
_cur_term->last_status = partition_balancer_status::in_progress;
} else if (plan_data.status == planner_status::waiting_for_reports) {
_cur_term->last_status = partition_balancer_status::starting;
} else if (
plan_data.failed_actions_count > 0
|| plan_data.status == planner_status::waiting_for_maintenance_end) {
} else if (plan_data.failed_actions_count > 0) {
_cur_term->last_status = partition_balancer_status::stalled;
} else {
_cur_term->last_status = partition_balancer_status::ready;
Expand Down
24 changes: 6 additions & 18 deletions src/v/cluster/partition_balancer_planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ class partition_balancer_planner::request_context {
std::vector<model::node_id> all_nodes;
absl::flat_hash_set<model::node_id> all_unavailable_nodes;
absl::flat_hash_set<model::node_id> timed_out_unavailable_nodes;
size_t num_nodes_in_maintenance = 0;
absl::flat_hash_set<model::node_id> decommissioning_nodes;
absl::flat_hash_map<model::node_id, node_disk_space> node_disk_reports;

Expand Down Expand Up @@ -237,13 +236,6 @@ void partition_balancer_planner::init_per_node_state(

ctx.all_nodes.push_back(id);

if (
broker.state.get_maintenance_state()
== model::maintenance_state::active) {
vlog(clusterlog.debug, "node {}: in maintenance", id);
ctx.num_nodes_in_maintenance += 1;
}

if (
broker.state.get_membership_state()
== model::membership_state::draining) {
Expand Down Expand Up @@ -1598,16 +1590,12 @@ partition_balancer_planner::plan_actions(
ctx, ctx.decommissioning_nodes, change_reason::node_decommissioning);

if (ctx.config().mode == model::partition_autobalancing_mode::continuous) {
if (ctx.num_nodes_in_maintenance == 0) {
co_await get_node_drain_actions(
ctx,
ctx.timed_out_unavailable_nodes,
change_reason::node_unavailable);
co_await get_rack_constraint_repair_actions(ctx);
co_await get_full_node_actions(ctx);
} else if (!result.violations.is_empty()) {
result.status = status::waiting_for_maintenance_end;
}
co_await get_node_drain_actions(
ctx,
ctx.timed_out_unavailable_nodes,
change_reason::node_unavailable);
co_await get_rack_constraint_repair_actions(ctx);
co_await get_full_node_actions(ctx);
}
co_await get_counts_rebalancing_actions(ctx);

Expand Down
1 change: 0 additions & 1 deletion src/v/cluster/partition_balancer_planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class partition_balancer_planner {
enum class status {
empty,
actions_planned,
waiting_for_maintenance_end,
waiting_for_reports,
missing_sizes,
};
Expand Down
12 changes: 7 additions & 5 deletions src/v/cluster/tests/partition_balancer_planner_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -743,11 +743,13 @@ FIXTURE_TEST(
auto plan_data = planner.plan_actions(hr, as).get();

check_violations(plan_data, unavailable_nodes, {});
BOOST_REQUIRE_EQUAL(plan_data.reassignments.size(), 0);
BOOST_REQUIRE(
plan_data.status
== cluster::partition_balancer_planner::status::
waiting_for_maintenance_end);
BOOST_REQUIRE_EQUAL(plan_data.reassignments.size(), 1);

std::unordered_set<model::node_id> expected_nodes(
{model::node_id(1), model::node_id(2), model::node_id(3)});

auto new_replicas = plan_data.reassignments.front().allocated.replicas();
check_expected_assignments(new_replicas, expected_nodes);
}

/*
Expand Down

0 comments on commit c9f3401

Please sign in to comment.