From 87fdaf5a7031481660dc8472f46b625b55cccbf9 Mon Sep 17 00:00:00 2001 From: Borys Date: Thu, 20 Mar 2025 15:20:20 +0200 Subject: [PATCH] feat: ignore managed_service_info flag for cluster (#4803) * feat: ignore managed_service_info flag for cluster --- src/server/cluster/cluster_family.cc | 19 +------------------ tests/dragonfly/cluster_test.py | 7 ++++--- 2 files changed, 5 insertions(+), 21 deletions(-) diff --git a/src/server/cluster/cluster_family.cc b/src/server/cluster/cluster_family.cc index 079697067..07ea6143f 100644 --- a/src/server/cluster/cluster_family.cc +++ b/src/server/cluster/cluster_family.cc @@ -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 ClusterFamily::GetShardInfos(ConnectionContext* } if (ClusterConfig::Current() != nullptr) { - return GetConfigForStats(cntx); + return ClusterConfig::Current()->GetConfig(); } return nullopt; } diff --git a/tests/dragonfly/cluster_test.py b/tests/dragonfly/cluster_test.py index a2ccc56ec..6db086a3b 100644 --- a/tests/dragonfly/cluster_test.py +++ b/tests/dragonfly/cluster_test.py @@ -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