system_keyspace: Move enable_features_on_startup to feature_service (cont)
Now move the code itself. No functional changes here. Signed-off-by: Pavel Emelyanov <xemul@scylladb.com>
This commit is contained in:
@@ -3364,46 +3364,6 @@ future<> system_keyspace::save_local_enabled_features(std::set<sstring> features
|
||||
co_await set_scylla_local_param(gms::feature_service::ENABLED_FEATURES_KEY, features_str);
|
||||
}
|
||||
|
||||
} namespace gms {
|
||||
|
||||
future<> feature_service::enable_features_on_startup(db::system_keyspace& sys_ks) {
|
||||
std::set<sstring> features_to_enable;
|
||||
const auto persisted_features = co_await db::system_keyspace::load_local_enabled_features();
|
||||
if (persisted_features.empty()) {
|
||||
co_return;
|
||||
}
|
||||
|
||||
const auto known_features = supported_feature_set();
|
||||
for (auto&& f : persisted_features) {
|
||||
db::slogger.debug("Enabling persisted feature '{}'", f);
|
||||
const bool is_registered_feat = _registered_features.contains(sstring(f));
|
||||
if (!is_registered_feat || !known_features.contains(f)) {
|
||||
if (is_registered_feat) {
|
||||
throw std::runtime_error(format(
|
||||
"Feature '{}' was previously enabled in the cluster but its support is disabled by this node. "
|
||||
"Set the corresponding configuration option to enable the support for the feature.", f));
|
||||
} else {
|
||||
throw std::runtime_error(format("Unknown feature '{}' was previously enabled in the cluster. "
|
||||
" That means this node is performing a prohibited downgrade procedure"
|
||||
" and should not be allowed to boot.", f));
|
||||
}
|
||||
}
|
||||
if (is_registered_feat) {
|
||||
features_to_enable.insert(std::move(f));
|
||||
}
|
||||
// If a feature is not in `registered_features` but still in `known_features` list
|
||||
// that means the feature name is used for backward compatibility and should be implicitly
|
||||
// enabled in the code by default, so just skip it.
|
||||
}
|
||||
|
||||
co_await container().invoke_on_all([&features_to_enable] (auto& srv) -> future<> {
|
||||
std::set<std::string_view> feat = boost::copy_range<std::set<std::string_view>>(features_to_enable);
|
||||
co_await srv.enable(std::move(feat));
|
||||
});
|
||||
}
|
||||
|
||||
} namespace db {
|
||||
|
||||
future<utils::UUID> system_keyspace::get_raft_group0_id() {
|
||||
auto opt = co_await get_scylla_local_param_as<utils::UUID>("raft_group0_id");
|
||||
co_return opt.value_or<utils::UUID>({});
|
||||
|
||||
@@ -216,6 +216,42 @@ future<> feature_service::enable_features_on_join(gossiper& g, db::system_keyspa
|
||||
return enabler->enable_features();
|
||||
}
|
||||
|
||||
future<> feature_service::enable_features_on_startup(db::system_keyspace& sys_ks) {
|
||||
std::set<sstring> features_to_enable;
|
||||
const auto persisted_features = co_await db::system_keyspace::load_local_enabled_features();
|
||||
if (persisted_features.empty()) {
|
||||
co_return;
|
||||
}
|
||||
|
||||
const auto known_features = supported_feature_set();
|
||||
for (auto&& f : persisted_features) {
|
||||
logger.debug("Enabling persisted feature '{}'", f);
|
||||
const bool is_registered_feat = _registered_features.contains(sstring(f));
|
||||
if (!is_registered_feat || !known_features.contains(f)) {
|
||||
if (is_registered_feat) {
|
||||
throw std::runtime_error(format(
|
||||
"Feature '{}' was previously enabled in the cluster but its support is disabled by this node. "
|
||||
"Set the corresponding configuration option to enable the support for the feature.", f));
|
||||
} else {
|
||||
throw std::runtime_error(format("Unknown feature '{}' was previously enabled in the cluster. "
|
||||
" That means this node is performing a prohibited downgrade procedure"
|
||||
" and should not be allowed to boot.", f));
|
||||
}
|
||||
}
|
||||
if (is_registered_feat) {
|
||||
features_to_enable.insert(std::move(f));
|
||||
}
|
||||
// If a feature is not in `registered_features` but still in `known_features` list
|
||||
// that means the feature name is used for backward compatibility and should be implicitly
|
||||
// enabled in the code by default, so just skip it.
|
||||
}
|
||||
|
||||
co_await container().invoke_on_all([&features_to_enable] (auto& srv) -> future<> {
|
||||
std::set<std::string_view> feat = boost::copy_range<std::set<std::string_view>>(features_to_enable);
|
||||
co_await srv.enable(std::move(feat));
|
||||
});
|
||||
}
|
||||
|
||||
future<> persistent_feature_enabler::enable_features() {
|
||||
auto loaded_peer_features = co_await _sys_ks.load_peer_features();
|
||||
auto&& features = _g.get_supported_features(loaded_peer_features, gossiper::ignore_features_of_local_node::no);
|
||||
|
||||
Reference in New Issue
Block a user