Skip to content

Commit

Permalink
feature_table: Add feature barrier for force reconfiguration API.
Browse files Browse the repository at this point in the history
  • Loading branch information
bharathv committed May 5, 2023
1 parent 4c1b420 commit 4099132
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 2 additions & 0 deletions src/v/features/feature_table.cc
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ std::string_view to_string_view(feature f) {
return "cloud_storage_manifest_format_v2";
case feature::transaction_partitioning:
return "transaction_partitioning";
case feature::force_partition_reconfiguration:
return "force_partition_reconfiguration";

/*
* testing features
Expand Down
7 changes: 7 additions & 0 deletions src/v/features/feature_table.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ enum class feature : std::uint64_t {
controller_snapshots = 1ULL << 23U,
cloud_storage_manifest_format_v2 = 1ULL << 24U,
transaction_partitioning = 1ULL << 25U,
force_partition_reconfiguration = 1ULL << 26U,

// Dummy features for testing only
test_alpha = 1ULL << 62U,
Expand Down Expand Up @@ -267,6 +268,12 @@ constexpr static std::array feature_schema{
feature::transaction_partitioning,
feature_spec::available_policy::always,
feature_spec::prepare_policy::always},
feature_spec{
cluster::cluster_version{10},
"force_partition_reconfiguration",
feature::force_partition_reconfiguration,
feature_spec::available_policy::always,
feature_spec::prepare_policy::always},

// For testing, a feature that does not auto-activate
feature_spec{
Expand Down
7 changes: 6 additions & 1 deletion src/v/redpanda/admin_server.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2810,8 +2810,13 @@ admin_server::unclean_abort_partition_reconfig_handler(
ss::future<ss::json::json_return_type>
admin_server::force_set_partition_replicas_handler(
std::unique_ptr<ss::http::request> req) {
auto ntp = parse_ntp_from_request(req->param);
if (unlikely(!_controller->get_feature_table().local().is_active(
features::feature::force_partition_reconfiguration))) {
throw ss::httpd::bad_request_exception(
"Feature not active yet, upgrade in progress?");
}

auto ntp = parse_ntp_from_request(req->param);
if (ntp == model::controller_ntp) {
throw ss::httpd::bad_request_exception(
fmt::format("Can't reconfigure a controller"));
Expand Down

0 comments on commit 4099132

Please sign in to comment.