@@ -84,27 +84,37 @@ if env | grep '^hugegraph\.' > /dev/null; then
8484 : " ${HG_SERVER_PD_REST_ENDPOINT:= } "
8585
8686 if [ -n " ${HG_SERVER_PD_REST_ENDPOINT} " ]; then
87- PD_REST =" ${HG_SERVER_PD_REST_ENDPOINT} "
87+ PD_REST_LIST =" ${HG_SERVER_PD_REST_ENDPOINT} "
8888 else
89- PD_REST =$( echo " $PD_PEERS " | sed ' s/:8686/:8620/g' | cut -d ' , ' -f1 )
89+ PD_REST_LIST =$( echo " $PD_PEERS " | sed ' s/:8686/:8620/g' )
9090 fi
9191
92- log " PD REST endpoint = $PD_REST "
92+ export PD_REST_LIST
93+ log " PD REST peers = $PD_REST_LIST "
9394 log " Timeout = ${WAIT_STORAGE_TIMEOUT_S} s"
9495
9596 timeout " ${WAIT_STORAGE_TIMEOUT_S} s" bash -c "
9697
9798 log() { echo '[wait-storage] '\"\$ 1\" ; }
9899
99- until curl ${PD_AUTH_ARGS} -f -s \
100- http://${PD_REST} /v1/health >/dev/null 2>&1; do
101- log 'PD not ready, retrying in 5s'
100+ check_any_pd() {
101+ for peer in \$ (echo \"\$ PD_REST_LIST\" | tr ',' ' '); do
102+ if curl ${PD_AUTH_ARGS} -f -s http://\$ {peer}/v1/health >/dev/null 2>&1; then
103+ echo \"\$ peer\"
104+ return 0
105+ fi
106+ done
107+ return 1
108+ }
109+
110+ until PD_REST=\$ (check_any_pd); do
111+ log 'No PD peer ready yet, retrying in 5s'
102112 sleep 5
103113 done
104- log ' PD health check PASSED'
114+ log \" PD health check PASSED via \$ PD_REST \"
105115
106116 until curl ${PD_AUTH_ARGS} -f -s \
107- http://${PD_REST} /v1/stores 2>/dev/null | \
117+ http://\ $ {PD_REST}/v1/stores 2>/dev/null | \
108118 grep -qi '\" state\" [[:space:]]*:[[:space:]]*\" Up\" '; do
109119 log 'No Up store yet, retrying in 5s'
110120 sleep 5
0 commit comments