github-actions[bot] commented on code in PR #65924:
URL: https://github.com/apache/doris/pull/65924#discussion_r3663591297


##########
docker/thirdparties/docker-compose/polaris/init-catalog.sh:
##########
@@ -19,25 +19,84 @@ set -eu
 
 HOST=${POLARIS_HOST:-polaris-s3}
 PORT=${POLARIS_PORT:-8181}
+ADMIN_PORT=${POLARIS_ADMIN_PORT:-8182}
 USER=${POLARIS_BOOTSTRAP_USER:-root}
 PASS=${POLARIS_BOOTSTRAP_PASSWORD:-secret123}
 CATALOG=${POLARIS_CATALOG_NAME:-minio}
 BASE_LOCATION=${CATALOG_BASE_LOCATION:-s3://warehouse/wh/}
 
-echo "[polaris-init] Waiting for Polaris health check at 
http://$HOST:$PORT/q/health ..."
-for i in $(seq 1 120); do
-  if curl -sSf "http://$HOST:8182/q/health"; >/dev/null; then
+CURL_CONNECT_TIMEOUT_SECONDS=${POLARIS_INIT_CONNECT_TIMEOUT_SECONDS:-5}
+CURL_REQUEST_TIMEOUT_SECONDS=${POLARIS_INIT_REQUEST_TIMEOUT_SECONDS:-15}
+CURL_RETRY_COUNT=${POLARIS_INIT_RETRY_COUNT:-3}
+CURL_RETRY_DELAY_SECONDS=${POLARIS_INIT_RETRY_DELAY_SECONDS:-2}
+CURL_RETRY_MAX_TIME_SECONDS=${POLARIS_INIT_RETRY_MAX_TIME_SECONDS:-45}
+HEALTH_CHECK_ATTEMPTS=${POLARIS_INIT_HEALTH_CHECK_ATTEMPTS:-60}
+HEALTH_CHECK_INTERVAL_SECONDS=${POLARIS_INIT_HEALTH_CHECK_INTERVAL_SECONDS:-2}
+HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS=${POLARIS_INIT_HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS:-2}
+TOKEN_RESPONSE_FILE=/tmp/polaris-token.json
+
+# Keep every network operation bounded when an endpoint accepts a connection 
but never responds.
+trap 'rc=$?; if [ "$rc" -ne 0 ]; then echo "[polaris-init] ERROR: 
Initialization failed with exit code $rc." >&2; fi' 0
+
+require_positive_integer() {
+  name=$1
+  value=$2
+  case "$value" in
+    ''|*[!0-9]*)
+      ;;
+    *)
+      if [ "$value" -gt 0 ] 2>/dev/null; then
+        return
+      fi
+      ;;
+  esac
+  echo "[polaris-init] ERROR: $name must be a positive integer, got '$value'." 
>&2
+  exit 1
+}
+
+require_positive_integer POLARIS_INIT_REQUEST_TIMEOUT_SECONDS 
"$CURL_REQUEST_TIMEOUT_SECONDS"
+require_positive_integer POLARIS_INIT_HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS 
"$HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS"
+
+curl_with_retry() {
+  curl -sS \
+    --connect-timeout "$CURL_CONNECT_TIMEOUT_SECONDS" \
+    --max-time "$CURL_REQUEST_TIMEOUT_SECONDS" \
+    --retry "$CURL_RETRY_COUNT" \
+    --retry-delay "$CURL_RETRY_DELAY_SECONDS" \
+    --retry-max-time "$CURL_RETRY_MAX_TIME_SECONDS" \
+    --retry-all-errors \
+    "$@"
+}
+
+echo "[polaris-init] Waiting for Polaris health check at 
http://$HOST:$ADMIN_PORT/q/health ..."
+health_check_succeeded=false
+i=1
+while [ "$i" -le "$HEALTH_CHECK_ATTEMPTS" ]; do
+  if curl -sSf \
+    --connect-timeout "$CURL_CONNECT_TIMEOUT_SECONDS" \
+    --max-time "$HEALTH_CHECK_REQUEST_TIMEOUT_SECONDS" \
+    "http://$HOST:$ADMIN_PORT/q/health"; >/dev/null; then
+    health_check_succeeded=true
     break
   fi
-  sleep 2
+  if [ "$i" -lt "$HEALTH_CHECK_ATTEMPTS" ]; then
+    sleep "$HEALTH_CHECK_INTERVAL_SECONDS"

Review Comment:
   The new interval override is forwarded verbatim, and the pinned 
`curlimages/curl:8.11.1` image's BusyBox `sleep` treats both `inf` and 
`infinity` as endless durations. With either value, one transient health-check 
failure blocks at this line forever, so later attempts and the EXIT diagnostic 
never run and the hang this PR is meant to eliminate returns. Please reject 
symbolic infinite durations (and validate the other advertised numeric controls 
as appropriate) before entering the loop, with an exact-image negative test for 
`inf`/`infinity`.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to