Hide the comma after cport when there is no hostname. (#12411)
According to the format shown in https://redis.io/commands/cluster-nodes/ ``` <ip:port@cport[,hostname[,auxiliary_field=value]*]> ``` when there is no hostname, and the auxiliary fields are hidden, the cluster topology should be ``` <ip:port@cport> ``` 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 ```
This commit is contained in:
parent
9b1d4f003d
commit
91011100ba
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user