From 5902dab67e275bbd97a9e7dfd75bff66c3bf81f6 Mon Sep 17 00:00:00 2001 From: James Lucas Date: Thu, 15 Dec 2022 04:10:15 -0600 Subject: [PATCH] Redis-Cluster: Ensure Proper Host Resolution (#14567) Ensure that cluster setup scripts support proper DNS resolution of Redis nodes running on nonstandard ports. Signed-off-by: James Lucas Signed-off-by: James Lucas --- .../debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh | 6 ++++-- .../debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh b/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh index 593db64cb328..acd1f137c0bb 100644 --- a/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh +++ b/bitnami/redis-cluster/6.2/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh @@ -201,7 +201,8 @@ redis_cluster_update_ips() { if [[ ! -f "${REDIS_DATA_DIR}/nodes.sh" ]]; then # It is the first initialization so store the nodes for node in "${nodes[@]}"; do - ip=$(wait_for_dns_lookup "$node" "$REDIS_DNS_RETRIES" 5) + read -r -a host_and_port <<< "$(to_host_and_port "$node")" + ip=$(wait_for_dns_lookup "${host_and_port[0]}" "$REDIS_DNS_RETRIES" 5) host_2_ip_array["$node"]="$ip" done echo "Storing map with hostnames and IPs" @@ -211,7 +212,8 @@ redis_cluster_update_ips() { . "${REDIS_DATA_DIR}/nodes.sh" # Update the IPs in the nodes.conf for node in "${nodes[@]}"; do - newIP=$(wait_for_dns_lookup "$node" "$REDIS_DNS_RETRIES" 5) + read -r -a host_and_port <<< "$(to_host_and_port "$node")" + newIP=$(wait_for_dns_lookup "${host_and_port[0]}" "$REDIS_DNS_RETRIES" 5) # The node can be new if we are updating the cluster, so catch the unbound variable error if [[ ${host_2_ip_array[$node]+true} ]]; then echo "Changing old IP ${host_2_ip_array[$node]} by the new one ${newIP}" diff --git a/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh b/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh index 593db64cb328..acd1f137c0bb 100644 --- a/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh +++ b/bitnami/redis-cluster/7.0/debian-11/rootfs/opt/bitnami/scripts/librediscluster.sh @@ -201,7 +201,8 @@ redis_cluster_update_ips() { if [[ ! -f "${REDIS_DATA_DIR}/nodes.sh" ]]; then # It is the first initialization so store the nodes for node in "${nodes[@]}"; do - ip=$(wait_for_dns_lookup "$node" "$REDIS_DNS_RETRIES" 5) + read -r -a host_and_port <<< "$(to_host_and_port "$node")" + ip=$(wait_for_dns_lookup "${host_and_port[0]}" "$REDIS_DNS_RETRIES" 5) host_2_ip_array["$node"]="$ip" done echo "Storing map with hostnames and IPs" @@ -211,7 +212,8 @@ redis_cluster_update_ips() { . "${REDIS_DATA_DIR}/nodes.sh" # Update the IPs in the nodes.conf for node in "${nodes[@]}"; do - newIP=$(wait_for_dns_lookup "$node" "$REDIS_DNS_RETRIES" 5) + read -r -a host_and_port <<< "$(to_host_and_port "$node")" + newIP=$(wait_for_dns_lookup "${host_and_port[0]}" "$REDIS_DNS_RETRIES" 5) # The node can be new if we are updating the cluster, so catch the unbound variable error if [[ ${host_2_ip_array[$node]+true} ]]; then echo "Changing old IP ${host_2_ip_array[$node]} by the new one ${newIP}"