feat: ignore managed_service_info flag for cluster (#4803)

* feat: ignore managed_service_info flag for cluster
This commit is contained in:
Borys 2025-03-20 15:20:20 +02:00 committed by adi_holden
parent e436452ffe
commit 87fdaf5a70
2 changed files with 5 additions and 21 deletions

View file

@ -63,23 +63,6 @@ constexpr char kIdNotFound[] = "syncid not found";
constexpr string_view kClusterDisabled =
"Cluster is disabled. Enabled via passing --cluster_mode=emulated|yes";
ClusterShardInfos GetConfigForStats(ConnectionContext* cntx) {
CHECK(!IsClusterEmulated());
CHECK(ClusterConfig::Current() != nullptr);
auto config = ClusterConfig::Current()->GetConfig();
if (cntx->conn()->IsPrivileged() || !absl::GetFlag(FLAGS_managed_service_info)) {
return config;
}
auto shards_info = config.Unwrap();
for (auto& node : shards_info) {
node.replicas.clear();
}
return shards_info;
}
} // namespace
ClusterFamily::ClusterFamily(ServerFamily* server_family) : server_family_(server_family) {
@ -122,7 +105,7 @@ std::optional<ClusterShardInfos> ClusterFamily::GetShardInfos(ConnectionContext*
}
if (ClusterConfig::Current() != nullptr) {
return GetConfigForStats(cntx);
return ClusterConfig::Current()->GetConfig();
}
return nullopt;
}

View file

@ -539,15 +539,16 @@ async def test_cluster_managed_service_info(df_factory):
assert await c_master.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
assert await c_master_admin.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
# this flag doesn't affect cluster anymore so the results will be the same
await c_master.execute_command("config set managed_service_info true")
assert await c_master.execute_command("CLUSTER SLOTS") == expected_hidden_cluster_slots
assert await c_master.execute_command("CLUSTER SLOTS") == expected_full_cluster_slots
assert await c_master_admin.execute_command("CLUSTER SLOTS") == expected_full_cluster_slots
assert await c_master.execute_command("CLUSTER NODES") == expected_hidden_cluster_nodes
assert await c_master.execute_command("CLUSTER NODES") == expected_full_cluster_nodes
assert await c_master_admin.execute_command("CLUSTER NODES") == expected_full_cluster_nodes
assert await c_master.execute_command("CLUSTER SHARDS") == expected_hidden_cluster_shards
assert await c_master.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
assert await c_master_admin.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards