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

Exit early on invariants change #743

Merged
Merged
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
4 changes: 4 additions & 0 deletions src/v/cluster/controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ ss::future<> controller::start() {
std::ref(_storage),
std::ref(_as));
})
.then([this] {
// validate configuration invariants to exit early
return _members_manager.local().validate_configuration_invariants();
})
.then([this] {
return _stm.start_single(
std::ref(clusterlog),
Expand Down
14 changes: 6 additions & 8 deletions src/v/cluster/members_manager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,13 @@ members_manager::members_manager(

ss::future<> members_manager::start() {
vlog(clusterlog.info, "starting cluster::members_manager...");
// validate node id change
return validate_configuration_invariants().then([this] {
// join raft0
if (!is_already_member()) {
join_raft0();
}

return start_config_changes_watcher();
});
// join raft0
if (!is_already_member()) {
join_raft0();
}

return start_config_changes_watcher();
}

ss::future<> members_manager::start_config_changes_watcher() {
Expand Down
4 changes: 2 additions & 2 deletions src/v/cluster/members_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class members_manager {

ss::future<> start();
ss::future<> stop();

ss::future<> validate_configuration_invariants();
ss::future<result<join_reply>> handle_join_request(model::broker);
ss::future<std::error_code> apply_update(model::record_batch);

Expand Down Expand Up @@ -75,7 +75,7 @@ class members_manager {
// Raft 0 config updates
ss::future<> handle_raft0_cfg_update(raft::group_configuration);
ss::future<> update_connections(patch<broker_ptr>);
ss::future<> validate_configuration_invariants();

ss::future<> start_config_changes_watcher();

ss::future<> maybe_update_current_node_configuration();
Expand Down
8 changes: 6 additions & 2 deletions src/v/cluster/partition_allocator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,12 @@ void partition_allocator::update_allocation_state(
[](const model::broker_shard& l, const model::broker_shard& r) {
return l.node_id > r.node_id;
});

auto it = find_node(std::cbegin(shards)->node_id);
auto node_id = std::cbegin(shards)->node_id;
auto it = find_node(node_id);
vassert(
it != _machines.end(),
"node: {} must exists in partition allocator, it currenlty does not",
node_id);
for (auto const& bs : shards) {
// Thanks to shards being sorted we need to do only
// as many lookups as there are brokers
Expand Down