From 38e9e8ed3818a7044d2ffd67588e1cd3126ac088 Mon Sep 17 00:00:00 2001 From: Stav-Levi <45394834+StavRLevi@users.noreply.github.com> Date: Mon, 21 Apr 2025 12:13:55 +0300 Subject: [PATCH] Fix port update not reflected in CLUSTER SLOTS (#13932) Close https://github.com/redis/redis/issues/13892 config set port cmd updates server.port. cluster slot retrieves information about cluster slots and their associated nodes. the fix updates this info when config set port cmd is done, so cluster slots cmd returns the right value. --- src/config.c | 1 + tests/unit/cluster/announced-endpoints.tcl | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/src/config.c b/src/config.c index bfbc8fd33..518a04249 100644 --- a/src/config.c +++ b/src/config.c @@ -2450,6 +2450,7 @@ static int updatePort(const char **err) { listener->bindaddr = server.bindaddr; listener->bindaddr_count = server.bindaddr_count; listener->port = server.port; + clusterUpdateMyselfAnnouncedPorts(); listener->ct = connectionByType(CONN_TYPE_SOCKET); if (changeListener(listener) == C_ERR) { *err = "Unable to listen on this port. Check server logs."; diff --git a/tests/unit/cluster/announced-endpoints.tcl b/tests/unit/cluster/announced-endpoints.tcl index becba2270..1eb40ac4b 100644 --- a/tests/unit/cluster/announced-endpoints.tcl +++ b/tests/unit/cluster/announced-endpoints.tcl @@ -47,4 +47,20 @@ start_cluster 2 2 {tags {external:skip cluster}} { R 0 config set cluster-announce-bus-port 0 assert_match "*@$base_bus_port *" [R 0 CLUSTER NODES] } + + test "CONFIG SET port updates cluster-announced port" { + # Get the original port and change to new_port + set orig_port [lindex [R 0 config get port] 1] + assert {$orig_port != ""} + + set new_port [find_available_port $baseport $count] + R 0 config set port $new_port + + # Verify that the new port appears in the output of cluster slots + wait_for_condition 50 100 { + [string match "*$new_port*" [R 0 cluster slots]] + } else { + fail "Cluster announced port was not updated in cluster slots" + } + } }