Skip to content

Commit

Permalink
[bitnami/redis-cluster] Allow setting IP_VERSION for DNS lookup
Browse files Browse the repository at this point in the history
Signed-off-by: Marcos Tenrero <mtenrero@allot.com>
  • Loading branch information
mtenrero committed Oct 22, 2024
1 parent 273fbb0 commit c421442
Showing 1 changed file with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,17 @@ wait_for_dns_lookup() {
local hostname="${1:?hostname is missing}"
local retries="${2:-5}"
local seconds="${3:-1}"
local ip_version="${IP_VERSION:-}"
check_host() {
if [[ $(dns_lookup "$hostname") == "" ]]; then
if [[ $(dns_lookup "$hostname" "$ip_version") == "" ]]; then
false
else
true
fi
}
# Wait for the host to be ready
retry_while "check_host ${hostname}" "$retries" "$seconds"
dns_lookup "$hostname"
dns_lookup "$hostname" "$ip_version"
}

########################
Expand All @@ -61,8 +62,9 @@ wait_for_dns_lookup() {
get_machine_ip() {
local -a ip_addresses
local hostname
local ip_version="${IP_VERSION:-}"
hostname="$(hostname)"
read -r -a ip_addresses <<< "$(dns_lookup "$hostname" | xargs echo)"
read -r -a ip_addresses <<< "$(dns_lookup "$hostname" "$ip_version"| xargs echo)"
if [[ "${#ip_addresses[@]}" -gt 1 ]]; then
warn "Found more than one IP address associated to hostname ${hostname}: ${ip_addresses[*]}, will use ${ip_addresses[0]}"
elif [[ "${#ip_addresses[@]}" -lt 1 ]]; then
Expand All @@ -86,7 +88,8 @@ get_machine_ip() {
#########################
is_hostname_resolved() {
local -r host="${1:?missing value}"
if [[ -n "$(dns_lookup "$host")" ]]; then
local ip_version="${IP_VERSION:-}"
if [[ -n "$(dns_lookup "$host" "$ip_version")" ]]; then
true
else
false
Expand Down Expand Up @@ -168,4 +171,4 @@ wait_for_http_connection() {
error "Could not connect to ${url}"
return 1
fi
}
}

0 comments on commit c421442

Please sign in to comment.