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:
Chen Tianjie 2023-07-16 11:31:42 +08:00 committed by GitHub
parent 9b1d4f003d
commit 91011100ba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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;