Skip to content

Commit 60f86d1

Browse files
committed
feat: ignore managed_service_info flag for cluster
1 parent ce5c44b commit 60f86d1

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

src/server/cluster/cluster_family.cc

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ ClusterShardInfos GetConfigForStats(ConnectionContext* cntx) {
6868
CHECK(ClusterConfig::Current() != nullptr);
6969

7070
auto config = ClusterConfig::Current()->GetConfig();
71-
if (cntx->conn()->IsPrivileged() || !absl::GetFlag(FLAGS_managed_service_info)) {
71+
if (cntx->conn()->IsPrivileged()) {
7272
return config;
7373
}
7474

src/server/cluster/cluster_family_test.cc

+8-8
Original file line numberDiff line numberDiff line change
@@ -224,14 +224,14 @@ TEST_F(ClusterFamilyTest, ClusterConfigFull) {
224224
])json"}),
225225
"OK");
226226

227-
string cluster_info = Run({"cluster", "info"}).GetString();
227+
string cluster_info = RunPrivileged({"cluster", "info"}).GetString();
228228
EXPECT_THAT(cluster_info, HasSubstr("cluster_state:ok"));
229229
EXPECT_THAT(cluster_info, HasSubstr("cluster_slots_assigned:16384"));
230230
EXPECT_THAT(cluster_info, HasSubstr("cluster_slots_ok:16384"));
231231
EXPECT_THAT(cluster_info, HasSubstr("cluster_known_nodes:2"));
232232
EXPECT_THAT(cluster_info, HasSubstr("cluster_size:1"));
233233

234-
EXPECT_THAT(Run({"cluster", "shards"}),
234+
EXPECT_THAT(RunPrivileged({"cluster", "shards"}),
235235
RespArray(ElementsAre("slots", //
236236
RespArray(ElementsAre(IntArg(0), IntArg(16'383))), //
237237
"nodes", //
@@ -253,7 +253,7 @@ TEST_F(ClusterFamilyTest, ClusterConfigFull) {
253253
"replication-offset", IntArg(0), //
254254
"health", "online")))))));
255255

256-
EXPECT_THAT(Run({"cluster", "slots"}),
256+
EXPECT_THAT(RunPrivileged({"cluster", "slots"}),
257257
RespArray(ElementsAre(IntArg(0), //
258258
IntArg(16'383), //
259259
RespArray(ElementsAre( //
@@ -265,7 +265,7 @@ TEST_F(ClusterFamilyTest, ClusterConfigFull) {
265265
IntArg(8'000), //
266266
"wxyz")))));
267267

268-
EXPECT_EQ(Run({"cluster", "nodes"}),
268+
EXPECT_EQ(RunPrivileged({"cluster", "nodes"}),
269269
"abcd1234 10.0.0.1:7000@7000 master - 0 0 0 connected 0-16383\n"
270270
"wxyz 10.0.0.10:8000@8000 slave abcd1234 0 0 0 connected\n");
271271
}
@@ -338,14 +338,14 @@ TEST_F(ClusterFamilyTest, ClusterConfigFullMultipleInstances) {
338338
])json"}),
339339
"OK");
340340

341-
string cluster_info = Run({"cluster", "info"}).GetString();
341+
string cluster_info = RunPrivileged({"cluster", "info"}).GetString();
342342
EXPECT_THAT(cluster_info, HasSubstr("cluster_state:ok"));
343343
EXPECT_THAT(cluster_info, HasSubstr("cluster_slots_assigned:16384"));
344344
EXPECT_THAT(cluster_info, HasSubstr("cluster_slots_ok:16384"));
345345
EXPECT_THAT(cluster_info, HasSubstr("cluster_known_nodes:7"));
346346
EXPECT_THAT(cluster_info, HasSubstr("cluster_size:2"));
347347

348-
EXPECT_THAT(Run({"cluster", "shards"}),
348+
EXPECT_THAT(RunPrivileged({"cluster", "shards"}),
349349
RespArray(ElementsAre(
350350
RespArray(ElementsAre("slots", //
351351
RespArray(ElementsAre(IntArg(0), IntArg(10'000))), //
@@ -404,7 +404,7 @@ TEST_F(ClusterFamilyTest, ClusterConfigFullMultipleInstances) {
404404
"replication-offset", IntArg(0), //
405405
"health", "fail")))))))));
406406

407-
EXPECT_THAT(Run({"cluster", "slots"}),
407+
EXPECT_THAT(RunPrivileged({"cluster", "slots"}),
408408
RespArray(ElementsAre( //
409409
RespArray(ElementsAre(IntArg(0), //
410410
IntArg(10'000), //
@@ -427,7 +427,7 @@ TEST_F(ClusterFamilyTest, ClusterConfigFullMultipleInstances) {
427427
IntArg(8'001), //
428428
"qwerty")))))));
429429

430-
EXPECT_THAT(Run({"cluster", "nodes"}),
430+
EXPECT_THAT(RunPrivileged({"cluster", "nodes"}),
431431
"abcd1234 10.0.0.1:7000@7000 master - 0 0 0 disconnected 0-10000\n"
432432
"wxyz 10.0.0.10:8000@8000 slave abcd1234 0 0 0 connected\n"
433433
"efgh7890 10.0.0.2:7001@7001 master - 0 0 0 connected 10001-16383\n"

tests/dragonfly/cluster_test.py

+6-3
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,8 @@ async def test_cluster_managed_service_info(df_factory):
459459
replica_id,
460460
]
461461
)
462-
assert await c_master.execute_command("CLUSTER SLOTS") == expected_full_cluster_slots
462+
# managed_service_info is ignored for cluster because we have "hidden" health for replica
463+
assert await c_master.execute_command("CLUSTER SLOTS") == expected_hidden_cluster_slots
463464
assert await c_master_admin.execute_command("CLUSTER SLOTS") == expected_full_cluster_slots
464465

465466
expected_hidden_cluster_nodes = {
@@ -489,7 +490,8 @@ async def test_cluster_managed_service_info(df_factory):
489490
"node_id": replica_id,
490491
"slots": [],
491492
}
492-
assert await c_master.execute_command("CLUSTER NODES") == expected_full_cluster_nodes
493+
# managed_service_info is ignored for cluster because we have "hidden" health for replica
494+
assert await c_master.execute_command("CLUSTER NODES") == expected_hidden_cluster_nodes
493495
assert await c_master_admin.execute_command("CLUSTER NODES") == expected_full_cluster_nodes
494496

495497
expected_hidden_cluster_shards = [
@@ -536,7 +538,8 @@ async def test_cluster_managed_service_info(df_factory):
536538
"online",
537539
]
538540
)
539-
assert await c_master.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
541+
# managed_service_info is ignored for cluster because we have "hidden" health for replica
542+
assert await c_master.execute_command("CLUSTER SHARDS") == expected_hidden_cluster_shards
540543
assert await c_master_admin.execute_command("CLUSTER SHARDS") == expected_full_cluster_shards
541544

542545
await c_master.execute_command("config set managed_service_info true")

0 commit comments

Comments
 (0)