diff --git a/src/Coordination/KeeperStateManager.cpp b/src/Coordination/KeeperStateManager.cpp index 4ddc1bc1348..e57ae7e7c19 100644 --- a/src/Coordination/KeeperStateManager.cpp +++ b/src/Coordination/KeeperStateManager.cpp @@ -26,6 +26,7 @@ KeeperStateManager::KeeperStateManager( const Poco::Util::AbstractConfiguration & config, const CoordinationSettingsPtr & coordination_settings) : my_server_id(my_server_id_) + , secure(config.getBool(config_prefix + ".raft_configuration.secure", false)) , log_store(nuraft::cs_new( config.getString(config_prefix + ".log_storage_path", config.getString("path", DBMS_DEFAULT_PATH) + "coordination/logs"), coordination_settings->rotate_log_storage_interval, coordination_settings->force_sync)) @@ -35,11 +36,12 @@ KeeperStateManager::KeeperStateManager( Poco::Util::AbstractConfiguration::Keys keys; config.keys(config_prefix + ".raft_configuration", keys); total_servers = keys.size(); - bool has_secure = false; - bool has_unsecure = false; for (const auto & server_key : keys) { + if (!startsWith(server_key, "server")) + continue; + std::string full_prefix = config_prefix + ".raft_configuration." + server_key; int server_id = config.getInt(full_prefix + ".id"); std::string hostname = config.getString(full_prefix + ".hostname"); @@ -47,10 +49,6 @@ KeeperStateManager::KeeperStateManager( bool can_become_leader = config.getBool(full_prefix + ".can_become_leader", true); int32_t priority = config.getInt(full_prefix + ".priority", 1); bool start_as_follower = config.getBool(full_prefix + ".start_as_follower", false); - bool is_secure = config.getBool(full_prefix + ".secure", false); - - has_secure |= is_secure; - has_unsecure |= !is_secure; if (start_as_follower) start_as_follower_servers.insert(server_id); @@ -61,15 +59,11 @@ KeeperStateManager::KeeperStateManager( { my_server_config = peer_config; my_port = port; - secure = is_secure; } cluster_config->get_servers().push_back(peer_config); } - if (has_secure && has_unsecure) - throw Exception(ErrorCodes::RAFT_ERROR, "Cluster must have all secure or all non-secure nodes. Mixing secure and unsecure nodes is not allowed"); - if (!my_server_config) throw Exception(ErrorCodes::RAFT_ERROR, "Our server id {} not found in raft_configuration section", my_server_id); diff --git a/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper1.xml b/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper1.xml index 3624c828645..ecbd50c72a6 100644 --- a/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper1.xml +++ b/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper1.xml @@ -13,13 +13,13 @@ + true 1 node1 44444 true 3 - true 2 @@ -28,7 +28,6 @@ true true 2 - true 3 @@ -37,7 +36,6 @@ true true 1 - true diff --git a/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper2.xml b/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper2.xml index 590816f3c3e..53129ae0a75 100644 --- a/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper2.xml +++ b/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper2.xml @@ -13,13 +13,13 @@ + true 1 node1 44444 true 3 - true 2 @@ -28,7 +28,6 @@ true true 2 - true 3 @@ -37,7 +36,6 @@ true true 1 - true diff --git a/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper3.xml b/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper3.xml index 6f2626b07de..4c685764ec0 100644 --- a/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper3.xml +++ b/tests/integration/test_keeper_internal_secure/configs/enable_secure_keeper3.xml @@ -13,13 +13,13 @@ + true 1 node1 44444 true 3 - true 2 @@ -28,7 +28,6 @@ true true 2 - true 3 @@ -37,7 +36,6 @@ true true 1 - true