From 52455f93b60f47bfcdb4daf309ef6cc51b939db6 Mon Sep 17 00:00:00 2001 From: Pavel Emelyanov Date: Mon, 21 Jul 2025 18:15:24 +0300 Subject: [PATCH] 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 --- gms/feature_service.cc | 60 +----------------------------------------- gms/feature_service.hh | 6 ++--- init.cc | 51 ++++++++++++++++++++++++++++++++++- 3 files changed, 53 insertions(+), 64 deletions(-) diff --git a/gms/feature_service.cc b/gms/feature_service.cc index ec9bb4e10e..4095156890 100644 --- a/gms/feature_service.cc +++ b/gms/feature_service.cc @@ -8,7 +8,6 @@ #include #include #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 disabled) { - feature_config fcfg; - fcfg.disabled_features = get_disabled_features_from_db_config(cfg, std::move(disabled)); - return fcfg; -} - -std::set get_disabled_features_from_db_config(const db::config& cfg, std::set 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<>(); } diff --git a/gms/feature_service.hh b/gms/feature_service.hh index 40403daaab..0704da1f44 100644 --- a/gms/feature_service.hh +++ b/gms/feature_service.hh @@ -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 disabled_features; }; -feature_config feature_config_from_db_config(const db::config& cfg, std::set disabled = {}); -std::set get_disabled_features_from_db_config(const db::config& cfg, std::set 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; /** diff --git a/init.cc b/init.cc index bd05822bfc..671c621731 100644 --- a/init.cc +++ b/init.cc @@ -18,6 +18,8 @@ logging::logger startlog("init"); +using namespace std::string_literals; + std::set 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 get_seeds_from_db_config(const db::config& cfg, } std::set get_disabled_features_from_db_config(const db::config& cfg, std::set 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>& configurable::configurables() {