Skip to content

Commit 2a45f82

Browse files
committed
fix(server): try all PD peers in wait-storage and fix wait-partition endpoint
1 parent 735a7dd commit 2a45f82

2 files changed

Lines changed: 19 additions & 9 deletions

File tree

hugegraph-server/hugegraph-dist/src/assembly/static/bin/wait-partition.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ set -euo pipefail
2020
: "${STORE_REST:?STORE_REST not set}"
2121

2222
timeout "${WAIT_PARTITION_TIMEOUT_S:-120}s" bash -c '
23-
until curl -fsS "http://${STORE_REST}/v1/partitions" 2>/dev/null | \
23+
until curl -fsS "http://${STORE_REST}" 2>/dev/null | \
2424
grep -q "\"partitionCount\":[1-9]"
2525
do
2626
echo "Waiting for partition assignment..."

hugegraph-server/hugegraph-dist/src/assembly/static/bin/wait-storage.sh

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)