Skip to content

Commit

Permalink
Merge pull request #4921 from jcsp/issue-4388-1node-maintenance
Browse files Browse the repository at this point in the history
admin: reject maintenance mode req on 1 node cluster
  • Loading branch information
dotnwat committed May 31, 2022
2 parents 4f010fa + 20f3597 commit 0a7cbd0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
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 @@ -1798,6 +1798,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

0 comments on commit 0a7cbd0

Please sign in to comment.