mirror of
https://github.com/dragonflydb/dragonfly.git
synced 2025-05-11 10:25:47 +02:00
feat: ignore managed_service_info flag for cluster (#4803)
* feat: ignore managed_service_info flag for cluster
This commit is contained in:
parent
e436452ffe
commit
87fdaf5a70
2 changed files with 5 additions and 21 deletions
|
@ -63,23 +63,6 @@ constexpr char kIdNotFound[] = "syncid not found";
|
||||||
constexpr string_view kClusterDisabled =
|
constexpr string_view kClusterDisabled =
|
||||||
"Cluster is disabled. Enabled via passing --cluster_mode=emulated|yes";
|
"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
|
} // namespace
|
||||||
|
|
||||||
ClusterFamily::ClusterFamily(ServerFamily* server_family) : server_family_(server_family) {
|
ClusterFamily::ClusterFamily(ServerFamily* server_family) : server_family_(server_family) {
|
||||||
|
@ -122,7 +105,7 @@ std::optional<ClusterShardInfos> ClusterFamily::GetShardInfos(ConnectionContext*
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ClusterConfig::Current() != nullptr) {
|
if (ClusterConfig::Current() != nullptr) {
|
||||||
return GetConfigForStats(cntx);
|
return ClusterConfig::Current()->GetConfig();
|
||||||
}
|
}
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
|
||||||
assert await c_master_admin.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")
|
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_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_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
|
assert await c_master_admin.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue