From 95f2320825b618c2539fa2c95608e835d9617d0a Mon Sep 17 00:00:00 2001 From: Shahar Mike Date: Tue, 3 Dec 2024 16:09:13 +0200 Subject: [PATCH] chore: Hide managed service info in `INFO` (#4248) Specifically: * `INFO REPLICATION` does not list the replicas, but does still show `connected_slaves` * `INFO SERVER` does not show `thread_count` and `os` Fixes #4173 --- src/server/cluster/cluster_family.cc | 3 +-- src/server/server_family.cc | 21 ++++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/server/cluster/cluster_family.cc b/src/server/cluster/cluster_family.cc index 698a49d8c..dc1ef944e 100644 --- a/src/server/cluster/cluster_family.cc +++ b/src/server/cluster/cluster_family.cc @@ -33,10 +33,9 @@ ABSL_FLAG(std::string, cluster_node_id, "", "ID within a cluster, used for slot assignment. MUST be unique. If empty, uses master " "replication ID (random string)"); -ABSL_FLAG(bool, managed_service_info, false, - "Hides some implementation details from users when true (i.e. in managed service env)"); ABSL_DECLARE_FLAG(int32_t, port); ABSL_DECLARE_FLAG(uint16_t, announce_port); +ABSL_DECLARE_FLAG(bool, managed_service_info); namespace dfly { namespace acl { diff --git a/src/server/server_family.cc b/src/server/server_family.cc index a4052c62f..573fa0ee7 100644 --- a/src/server/server_family.cc +++ b/src/server/server_family.cc @@ -127,6 +127,9 @@ ABSL_FLAG(bool, s3_sign_payload, true, ABSL_FLAG(bool, info_replication_valkey_compatible, true, "when true - output valkey compatible values for info-replication"); +ABSL_FLAG(bool, managed_service_info, false, + "Hides some implementation details from users when true (i.e. in managed service env)"); + ABSL_DECLARE_FLAG(int32_t, port); ABSL_DECLARE_FLAG(bool, cache_mode); ABSL_DECLARE_FLAG(uint32_t, hz); @@ -2222,10 +2225,12 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { append("dragonfly_version", GetVersion()); append("redis_mode", GetRedisMode()); append("arch_bits", 64); - append("os", GetOSString()); + if (!absl::GetFlag(FLAGS_managed_service_info)) { + append("os", GetOSString()); + append("thread_count", service_.proactor_pool().size()); + } append("multiplexing_api", multiplex_api); append("tcp_port", GetFlag(FLAGS_port)); - append("thread_count", service_.proactor_pool().size()); uint64_t uptime = time(NULL) - start_time_; append("uptime_in_seconds", uptime); @@ -2487,11 +2492,13 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { append("role", "master"); append("connected_slaves", replicas_info.size()); - for (size_t i = 0; i < replicas_info.size(); i++) { - auto& r = replicas_info[i]; - // e.g. slave0:ip=172.19.0.3,port=6379,state=full_sync - append(StrCat("slave", i), StrCat("ip=", r.address, ",port=", r.listening_port, - ",state=", r.state, ",lag=", r.lsn_lag)); + if (!absl::GetFlag(FLAGS_managed_service_info)) { + for (size_t i = 0; i < replicas_info.size(); i++) { + auto& r = replicas_info[i]; + // e.g. slave0:ip=172.19.0.3,port=6379,state=full_sync + append(StrCat("slave", i), StrCat("ip=", r.address, ",port=", r.listening_port, + ",state=", r.state, ",lag=", r.lsn_lag)); + } } append("master_replid", master_replid_); } else {