From 9f09a62ad29531e0003fa5199fc3b35bf98e7961 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 17 Aug 2026 05:37:04 -0400 Subject: [PATCH] fix(docker-dev): guard the deploy POST against transport-level curl failure; bound both curls with --max-time --- docker-dev/deploy.sh | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/docker-dev/deploy.sh b/docker-dev/deploy.sh index 4309f35b..d3202c80 100755 --- a/docker-dev/deploy.sh +++ b/docker-dev/deploy.sh @@ -22,6 +22,10 @@ # ./deploy.sh artifact.json # send that file as the JSON request body # cat artifact.json | ./deploy.sh # +# NOTE (unverified against a live rig): the no-body invocation sends +# `Content-Type: application/json` with an empty body. Whether the minimal-API +# `DeployRequest?` parameter binds that as null or answers 400 has not been confirmed. +# set -euo pipefail BASE_URL="${OTOPCUA_ADMIN_URL:-http://localhost:9200}" @@ -36,7 +40,8 @@ echo "Waiting for $READY_URL (up to ${READY_TIMEOUT_SECONDS}s)..." deadline=$(( $(date +%s) + READY_TIMEOUT_SECONDS )) ready=0 while [ "$(date +%s)" -lt "$deadline" ]; do - code="$(curl -s -o /dev/null -w "%{http_code}" "$READY_URL" || true)" + # --max-time bounds a connected-but-hung backend, so one poll can never eat the budget. + code="$(curl -s --max-time 10 -o /dev/null -w "%{http_code}" "$READY_URL" || true)" if [ "$code" = "200" ]; then ready=1 break @@ -53,7 +58,7 @@ fi echo "Ready. Posting deployment..." # --- 2. the single, un-retried POST ------------------------------------------ -curl_args=(-s -w '\n%{http_code}' -X POST "$DEPLOY_URL" +curl_args=(-s --max-time 60 -w '\n%{http_code}' -X POST "$DEPLOY_URL" -H "X-Api-Key: $API_KEY" -H "Content-Type: application/json") @@ -64,7 +69,12 @@ elif [ ! -t 0 ]; then curl_args+=(--data-binary @-) fi -response="$(curl "${curl_args[@]}")" +# Guarded: a transport-level curl failure (connection refused/reset, timeout) must not trip +# `set -e` before the status/body reporting below — that reporting is the whole point here. +if ! response="$(curl "${curl_args[@]}")"; then + echo "ERROR: POST $DEPLOY_URL failed (curl could not complete the request)." >&2 + exit 1 +fi status="$(printf '%s' "$response" | tail -n1)" body="$(printf '%s' "$response" | sed '$d')"