From 91011100ba57b138b729a819787eec75df27b844 Mon Sep 17 00:00:00 2001 From: Chen Tianjie Date: Sun, 16 Jul 2023 11:31:42 +0800 Subject: [PATCH] Hide the comma after cport when there is no hostname. (#12411) According to the format shown in https://redis.io/commands/cluster-nodes/ ``` ``` when there is no hostname, and the auxiliary fields are hidden, the cluster topology should be ``` ``` However in the code we always print the hostname even when it is an empty string, leaving an unnecessary comma tailing after cport, which is weird and conflicts with the doc. ``` 94ca2f6cf85228a49fde7b738ee1209de7bee325 127.0.0.1:6379@16379, myself,master - 0 0 0 connected 0-16383 ``` --- src/cluster.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cluster.c b/src/cluster.c index 9e4cfd273..b017b9385 100644 --- a/src/cluster.c +++ b/src/cluster.c @@ -5230,12 +5230,12 @@ sds clusterGenNodeDescription(client *c, clusterNode *node, int tls_primary) { if (sdslen(node->hostname) != 0) { ci = sdscatfmt(ci,",%s", node->hostname); } - if (sdslen(node->hostname) == 0) { - ci = sdscatfmt(ci,",", 1); - } /* Don't expose aux fields to any clients yet but do allow them * to be persisted to nodes.conf */ if (c == NULL) { + if (sdslen(node->hostname) == 0) { + ci = sdscatfmt(ci,",", 1); + } for (int i = af_count-1; i >=0; i--) { if ((tls_primary && i == af_tls_port) || (!tls_primary && i == af_tcp_port)) { continue;