gms,init: Move get_disabled_features_from_db_config() from gms

Now when all callers are decoupled from gms config generating code, the
latter can be decoupled from the db::config.

Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
Pavel Emelyanov
2025-07-21 18:15:24 +03:00
parent 8220974e76
commit 52455f93b6
3 changed files with 53 additions and 64 deletions

View File

@@ -8,7 +8,6 @@
#include <seastar/core/seastar.hh>
#include <seastar/core/smp.hh>
#include "utils/log.hh"
#include "db/config.hh"
#include "gms/feature.hh"
#include "gms/feature_service.hh"
#include "db/system_keyspace.hh"
@@ -31,7 +30,7 @@ static bool is_test_only_feature_deprecated() {
return utils::get_local_injector().enter(enable_test_feature_as_deprecated_error_injection_name);
}
static bool is_test_only_feature_enabled() {
bool is_test_only_feature_enabled() {
return utils::get_local_injector().enter(enable_test_feature_error_injection_name)
|| is_test_only_feature_deprecated();
}
@@ -48,63 +47,6 @@ feature_service::feature_service(feature_config cfg) : _config(cfg) {
}
}
feature_config feature_config_from_db_config(const db::config& cfg, std::set<sstring> disabled) {
feature_config fcfg;
fcfg.disabled_features = get_disabled_features_from_db_config(cfg, std::move(disabled));
return fcfg;
}
std::set<sstring> get_disabled_features_from_db_config(const db::config& cfg, std::set<sstring> disabled) {
switch (sstables::version_from_string(cfg.sstable_format())) {
case sstables::sstable_version_types::md:
logger.warn("sstable_format must be 'me', '{}' is specified", cfg.sstable_format());
break;
case sstables::sstable_version_types::me:
break;
default:
SCYLLA_ASSERT(false && "Invalid sstable_format");
}
if (!cfg.enable_user_defined_functions()) {
disabled.insert("UDF");
} else {
if (!cfg.check_experimental(db::experimental_features_t::feature::UDF)) {
throw std::runtime_error(
"You must use both enable_user_defined_functions and experimental_features:udf "
"to enable user-defined functions");
}
}
if (!cfg.check_experimental(db::experimental_features_t::feature::ALTERNATOR_STREAMS)) {
disabled.insert("ALTERNATOR_STREAMS"s);
}
if (!cfg.check_experimental(db::experimental_features_t::feature::KEYSPACE_STORAGE_OPTIONS)) {
disabled.insert("KEYSPACE_STORAGE_OPTIONS"s);
}
if (!cfg.check_experimental(db::experimental_features_t::feature::VIEWS_WITH_TABLETS)) {
disabled.insert("VIEWS_WITH_TABLETS"s);
}
if (cfg.force_gossip_topology_changes()) {
if (cfg.enable_tablets_by_default()) {
throw std::runtime_error("Tablets cannot be enabled with gossip topology changes. Use either --tablets-mode-for-new-keyspaces=enabled|enforced or --force-gossip-topology-changes, but not both.");
}
logger.warn("The tablets feature is disabled due to forced gossip topology changes");
disabled.insert("TABLETS"s);
}
if (!cfg.table_digest_insensitive_to_expiry()) {
disabled.insert("TABLE_DIGEST_INSENSITIVE_TO_EXPIRY"s);
}
if (!cfg.commitlog_use_fragmented_entries()) {
disabled.insert("FRAGMENTED_COMMITLOG_ENTRIES"s);
}
if (!is_test_only_feature_enabled()) {
disabled.insert("TEST_ONLY_FEATURE"s);
}
return disabled;
}
future<> feature_service::stop() {
return make_ready_future<>();
}

View File

@@ -20,7 +20,6 @@
#include "gms/feature.hh"
namespace db {
class config;
class system_keyspace;
}
namespace service { class storage_service; }
@@ -35,9 +34,6 @@ struct feature_config {
std::set<sstring> disabled_features;
};
feature_config feature_config_from_db_config(const db::config& cfg, std::set<sstring> disabled = {});
std::set<sstring> get_disabled_features_from_db_config(const db::config& cfg, std::set<sstring> disabled = {});
class unsupported_feature_exception : public std::runtime_error {
public:
unsupported_feature_exception(std::string what)
@@ -45,6 +41,8 @@ public:
{}
};
bool is_test_only_feature_enabled();
using namespace std::literals;
/**

51
init.cc
View File

@@ -18,6 +18,8 @@
logging::logger startlog("init");
using namespace std::string_literals;
std::set<gms::inet_address> get_seeds_from_db_config(const db::config& cfg,
const gms::inet_address broadcast_address,
const bool fail_on_lookup_error) {
@@ -69,7 +71,54 @@ std::set<gms::inet_address> get_seeds_from_db_config(const db::config& cfg,
}
std::set<sstring> get_disabled_features_from_db_config(const db::config& cfg, std::set<sstring> disabled) {
return gms::get_disabled_features_from_db_config(cfg, std::move(disabled));
switch (sstables::version_from_string(cfg.sstable_format())) {
case sstables::sstable_version_types::md:
startlog.warn("sstable_format must be 'me', '{}' is specified", cfg.sstable_format());
break;
case sstables::sstable_version_types::me:
break;
default:
SCYLLA_ASSERT(false && "Invalid sstable_format");
}
if (!cfg.enable_user_defined_functions()) {
disabled.insert("UDF");
} else {
if (!cfg.check_experimental(db::experimental_features_t::feature::UDF)) {
throw std::runtime_error(
"You must use both enable_user_defined_functions and experimental_features:udf "
"to enable user-defined functions");
}
}
if (!cfg.check_experimental(db::experimental_features_t::feature::ALTERNATOR_STREAMS)) {
disabled.insert("ALTERNATOR_STREAMS"s);
}
if (!cfg.check_experimental(db::experimental_features_t::feature::KEYSPACE_STORAGE_OPTIONS)) {
disabled.insert("KEYSPACE_STORAGE_OPTIONS"s);
}
if (!cfg.check_experimental(db::experimental_features_t::feature::VIEWS_WITH_TABLETS)) {
disabled.insert("VIEWS_WITH_TABLETS"s);
}
if (cfg.force_gossip_topology_changes()) {
if (cfg.enable_tablets_by_default()) {
throw std::runtime_error("Tablets cannot be enabled with gossip topology changes. Use either --tablets-mode-for-new-keyspaces=enabled|enforced or --force-gossip-topology-changes, but not both.");
}
startlog.warn("The tablets feature is disabled due to forced gossip topology changes");
disabled.insert("TABLETS"s);
}
if (!cfg.table_digest_insensitive_to_expiry()) {
disabled.insert("TABLE_DIGEST_INSENSITIVE_TO_EXPIRY"s);
}
if (!cfg.commitlog_use_fragmented_entries()) {
disabled.insert("FRAGMENTED_COMMITLOG_ENTRIES"s);
}
if (!gms::is_test_only_feature_enabled()) {
disabled.insert("TEST_ONLY_FEATURE"s);
}
return disabled;
}
std::vector<std::reference_wrapper<configurable>>& configurable::configurables() {