Skip to content

Commit

Permalink
c/partition_balancer: planner cancelations
Browse files Browse the repository at this point in the history
planner cancel movement to unavailable nodes
  • Loading branch information
ZeDRoman committed Jul 6, 2022
1 parent 6148d64 commit 974815d
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 19 deletions.
47 changes: 35 additions & 12 deletions src/v/cluster/partition_balancer_planner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -395,26 +395,49 @@ void partition_balancer_planner::get_full_node_reassignments(
}
}

std::vector<ntp_reassignments>
partition_balancer_planner::get_ntp_reassignments(
void partition_balancer_planner::get_unavailable_node_movement_cancelations(
std::vector<model::ntp>& cancelations,
const reallocation_request_state& rrs) {
for (auto& update : _topic_table.in_progress_updates()) {
if (
update.second.state
!= topic_table::in_progress_state::update_requested) {
continue;
}
auto current_assignments = _topic_table.get_partition_assignment(
update.first);
if (!current_assignments.has_value()) {
continue;
}
for (auto& r : current_assignments->replicas) {
if (rrs.unavailable_nodes.contains(r.node_id)) {
cancelations.push_back(update.first);
continue;
}
}
}
}

planner_result partition_balancer_planner::get_ntp_reassignments(
const cluster_health_report& health_report,
const std::vector<raft::follower_metrics>& follower_metrics) {
reallocation_request_state rrs;
planner_result result;

calculate_unavailable_nodes(follower_metrics, rrs);

if (_topic_table.has_updates_in_progress()) {
return {};
get_unavailable_node_movement_cancelations(result.cancelations, rrs);
return result;
}

reallocation_request_state rrs;
std::vector<ntp_reassignments> reassignments;

init_ntp_sizes_and_node_disk_reports_from_health_report(health_report, rrs);

calculate_unavailable_nodes(follower_metrics, rrs);
calculate_nodes_with_disk_constraints_violation(rrs);

get_unavailable_nodes_reassignments(reassignments, rrs);
get_full_node_reassignments(reassignments, rrs);
get_unavailable_nodes_reassignments(result.reassignments, rrs);
get_full_node_reassignments(result.reassignments, rrs);

return reassignments;
return result;
}

} // namespace cluster
} // namespace cluster
10 changes: 4 additions & 6 deletions src/v/cluster/partition_balancer_planner.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,6 @@

namespace cluster {

struct ntp_reassignments {
model::ntp ntp;
allocation_units allocation_units;
};

struct planner_config {
double max_disk_usage_ratio;
// Size of partitions that can be planned to move in one request
Expand All @@ -38,7 +33,7 @@ class partition_balancer_planner {
topic_table& topic_table,
partition_allocator& partition_allocator);

std::vector<ntp_reassignments> get_ntp_reassignments(
planner_result get_ntp_reassignments(
const cluster_health_report&, const std::vector<raft::follower_metrics>&);

private:
Expand Down Expand Up @@ -72,6 +67,9 @@ class partition_balancer_planner {
void get_full_node_reassignments(
std::vector<ntp_reassignments>&, reallocation_request_state&);

void get_unavailable_node_movement_cancelations(
std::vector<model::ntp>& cancelations, const reallocation_request_state&);

void calculate_nodes_with_disk_constraints_violation(
reallocation_request_state&);

Expand Down
13 changes: 12 additions & 1 deletion src/v/cluster/partition_balancer_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

#pragma once

#include "cluster/scheduling/types.h"
#include "model/fundamental.h"
#include "model/metadata.h"

Expand Down Expand Up @@ -37,4 +38,14 @@ struct node_disk_space {
}
};

} // namespace cluster
struct ntp_reassignments {
model::ntp ntp;
allocation_units allocation_units;
};

struct planner_result {
std::vector<ntp_reassignments> reassignments;
std::vector<model::ntp> cancelations;
};

} // namespace cluster

0 comments on commit 974815d

Please sign in to comment.