support whole cluster info for INFO command in cluster section (#2876)

Allow users to more easily get cluster information.

Signed-off-by: zhaozhao.zz <zhaozhao.zz@alibaba-inc.com>
This commit is contained in:
zhaozhao.zz 2025-12-05 01:34:52 +08:00 committed by GitHub
parent 3d65a4aecd
commit 04d0bba398
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 5 additions and 5 deletions

View File

@ -898,7 +898,7 @@ void clusterCommand(client *c) {
} else if (!strcasecmp(c->argv[1]->ptr, "info") && c->argc == 2) {
/* CLUSTER INFO */
sds info = genClusterInfoString();
sds info = genClusterInfoString(sdsempty());
/* Produce the reply protocol. */
addReplyVerbatim(c, info, sdslen(info), "txt");

View File

@ -75,7 +75,7 @@ unsigned long getClusterConnectionsCount(void);
int isClusterHealthy(void);
sds clusterGenNodesDescription(client *c, int filter, int tls_primary);
sds genClusterInfoString(void);
sds genClusterInfoString(sds info);
/* handle implementation specific debug cluster commands. Return 1 if handled, 0 otherwise. */
int handleDebugClusterCommand(client *c);
const char **clusterDebugCommandExtendedHelp(void);

View File

@ -7041,8 +7041,7 @@ void clusterCommandShards(client *c) {
dictReleaseIterator(di);
}
sds genClusterInfoString(void) {
sds info = sdsempty();
sds genClusterInfoString(sds info) {
char *statestr[] = {"ok", "fail"};
int slots_assigned = 0, slots_ok = 0, slots_pfail = 0, slots_fail = 0;

View File

@ -1862,7 +1862,7 @@ __attribute__((noinline)) void logStackTrace(void *eip, int uplevel, int current
#endif /* HAVE_BACKTRACE */
sds genClusterDebugString(sds infostring) {
sds cluster_info = genClusterInfoString();
sds cluster_info = genClusterInfoString(sdsempty());
sds cluster_nodes = clusterGenNodesDescription(NULL, 0, 0);
infostring = sdscatprintf(infostring, "\r\n# Cluster info\r\n");

View File

@ -6433,6 +6433,7 @@ sds genValkeyInfoString(dict *section_dict, int all_sections, int everything) {
"# Cluster\r\n"
"cluster_enabled:%d\r\n",
server.cluster_enabled);
if (server.cluster_enabled) info = genClusterInfoString(info);
}
/* Scripting engines */