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

[v22.1.x] admin: reject maintenance mode req on 1 node cluster #4986

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
11 changes: 11 additions & 0 deletions src/v/cluster/members_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,17 @@ members_table::apply(model::offset version, maintenance_mode_cmd cmd) {
return errc::success;
}

if (_brokers.size() < 2) {
// Maintenance mode is refused on size 1 clusters in the admin API, but
// we might be upgrading from a version that didn't have the validation.
vlog(
clusterlog.info,
"Dropping maintenance mode enable operation on single node cluster");

// Return success to enable progress: this is a clean no-op.
return errc::success;
}

if (
target->second->get_maintenance_state()
== model::maintenance_state::active) {
Expand Down
7 changes: 7 additions & 0 deletions src/v/redpanda/admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1809,6 +1809,13 @@ void admin_server::register_broker_routes() {
throw ss::httpd::bad_request_exception(
"Maintenance mode feature not active (upgrade in progress?)");
}

if (
_controller->get_members_table().local().all_brokers().size() < 2) {
throw ss::httpd::bad_request_exception(
"Maintenance mode may not be used on a single node cluster");
}

model::node_id id = parse_broker_id(*req);
auto ec = co_await _controller->get_members_frontend()
.local()
Expand Down