From e42c0764aee86d679652cfb817c9fa1adc4307b8 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Thu, 9 Jan 2025 11:59:36 +0200 Subject: [PATCH 1/2] fix: show managed stuff on privileged port --- src/server/server_family.cc | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/server/server_family.cc b/src/server/server_family.cc index e897e1f2f423..bb263eb2d836 100644 --- a/src/server/server_family.cc +++ b/src/server/server_family.cc @@ -2255,7 +2255,8 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { append("dragonfly_version", GetVersion()); append("redis_mode", GetRedisMode()); append("arch_bits", 64); - if (!absl::GetFlag(FLAGS_managed_service_info)) { + + if (!absl::GetFlag(FLAGS_managed_service_info) || cmd_cntx.conn_cntx->conn()->IsPrivileged()) { append("os", GetOSString()); append("thread_count", service_.proactor_pool().size()); } @@ -2526,7 +2527,8 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { append("role", "master"); append("connected_slaves", replicas_info.size()); - if (!absl::GetFlag(FLAGS_managed_service_info)) { + if (!absl::GetFlag(FLAGS_managed_service_info) || + cmd_cntx.conn_cntx->conn()->IsPrivileged()) { 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 From dcc3dfd8e8e344b7cca3ec41b1a8044dfedd71f5 Mon Sep 17 00:00:00 2001 From: Roman Gershman Date: Thu, 9 Jan 2025 12:33:29 +0200 Subject: [PATCH 2/2] chore: comments --- src/server/server_family.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/server/server_family.cc b/src/server/server_family.cc index bb263eb2d836..96fafc891950 100644 --- a/src/server/server_family.cc +++ b/src/server/server_family.cc @@ -2247,6 +2247,9 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { ServerState* ss = ServerState::tlocal(); + bool show_managed_info = + !absl::GetFlag(FLAGS_managed_service_info) || cmd_cntx.conn_cntx->conn()->IsPrivileged(); + if (should_enter("SERVER")) { auto kind = ProactorBase::me()->GetKind(); const char* multiplex_api = (kind == ProactorBase::IOURING) ? "iouring" : "epoll"; @@ -2256,7 +2259,7 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { append("redis_mode", GetRedisMode()); append("arch_bits", 64); - if (!absl::GetFlag(FLAGS_managed_service_info) || cmd_cntx.conn_cntx->conn()->IsPrivileged()) { + if (show_managed_info) { append("os", GetOSString()); append("thread_count", service_.proactor_pool().size()); } @@ -2527,8 +2530,7 @@ void ServerFamily::Info(CmdArgList args, const CommandContext& cmd_cntx) { append("role", "master"); append("connected_slaves", replicas_info.size()); - if (!absl::GetFlag(FLAGS_managed_service_info) || - cmd_cntx.conn_cntx->conn()->IsPrivileged()) { + if (show_managed_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