Skip to content

Commit

Permalink
cluster: Sanction redpanda.leaders.preference on invalid license
Browse files Browse the repository at this point in the history
Implements CORE-8042 - Sanction-22

If there is no valid license, request to create a topic with
redpanda.leaders.preference enabled will be rejected.
  • Loading branch information
IoannisRP committed Nov 11, 2024
1 parent ad5577a commit c5cb776
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/v/cluster/topics_frontend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "cluster/topic_recovery_validator.h"
#include "cluster/types.h"
#include "config/configuration.h"
#include "config/leaders_preference.h"
#include "data_migration_types.h"
#include "features/feature_table.h"
#include "fwd.h"
Expand Down Expand Up @@ -81,6 +82,13 @@ std::vector<std::string_view> get_enterprise_features(
if (cfg.is_schema_id_validation_enabled()) {
features.emplace_back("schema ID validation");
}
if (const auto leaders_pref = cfg.cfg.properties.leaders_preference;
leaders_pref
&& config::shard_local_cfg()
.default_leaders_preference.check_restricted(
leaders_pref.value())) {
features.emplace_back("leadership pinning");
}
return features;
}

Expand Down
9 changes: 8 additions & 1 deletion src/v/kafka/server/tests/create_topics_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
// the Business Source License, use of this software will be governed
// by the Apache License, Version 2.0

#include "config/leaders_preference.h"
#include "container/fragmented_vector.h"
#include "kafka/protocol/create_topics.h"
#include "kafka/protocol/metadata.h"
Expand Down Expand Up @@ -463,7 +464,13 @@ FIXTURE_TEST(unlicensed_rejected, create_topic_fixture) {
with(kafka::topic_property_record_key_schema_id_validation_compat, true),
with(kafka::topic_property_record_value_schema_id_validation, true),
with(
kafka::topic_property_record_value_schema_id_validation_compat, true)};
kafka::topic_property_record_value_schema_id_validation_compat, true),
// pin_leadership_props
with(
kafka::topic_property_leaders_preference,
config::leaders_preference{
.type = config::leaders_preference::type_t::racks,
.racks = {model::rack_id{"A"}}})};

auto client = make_kafka_client().get();
client.connect().get();
Expand Down

0 comments on commit c5cb776

Please sign in to comment.