diff --git a/components/node/files/scripts/common.sh b/components/node/files/scripts/common.sh index 03b097c..feb0923 100644 --- a/components/node/files/scripts/common.sh +++ b/components/node/files/scripts/common.sh @@ -16,17 +16,27 @@ pingSentinel() { getPrimaryInfo() { masterName=${VALKEY_MASTER_NAME:-"mymaster"} + it="${1:-0}" info=$(valkey-cli --csv -h ${VALKEY_HEADLESS_SERVICE} -p ${VALKEY_SENTINEL_PORT} sentinel get-primary-addr-by-name "${masterName}"| \ awk -F ',' '{ gsub(/"/,"",$0); print $1 " " $2 }') if [ -z "${info}" ]; then echo "Failed to get primary info for master '${masterName}'" - getPrimaryInfo - #return 1 + it=$((it + 1)) + getPrimaryInfo ${it} + if [ ${it} -ge 10 ]; then + echo "Failed to get primary info after 5 attempts" + return 1 + fi fi if [[ "${info}" =~ /^NULL/ ]]; then - getPrimaryInfo + it=$((it + 1)) + getPrimaryInfo ${it} + if [ ${it} -ge 10 ]; then + echo "Failed to get primary info after 5 attempts" + return 1 + fi fi echo "${info}" return ${?}