mirror of
https://github.com/openclaw/openclaw.git
synced 2026-10-03 09:39:25 +00:00
Artifact and tool acquisition can recover from provider transport errors without repeating tests. Existing recovery paths did not consistently identify these attempts in GitHub annotations. Emit warnings only when infrastructure recovery fires, preserve immutable inputs and budgets, and keep terminal errors fatal. A synthetic HTTP 503 then 200 probe retained the exit status and produced one warning; a normal download produced none. Owner tests, syntax and workflow checks passed.
60 lines
1.8 KiB
Bash
60 lines
1.8 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
SCRIPT_DIR="${BASH_SOURCE[0]%/*}"
|
|
# shellcheck source=scripts/lib/host-timeout.sh
|
|
source "$SCRIPT_DIR/lib/host-timeout.sh"
|
|
|
|
if [[ "$#" -ne 1 || -z "${1// }" ]]; then
|
|
echo "usage: $0 <image>" >&2
|
|
exit 2
|
|
fi
|
|
|
|
image="$1"
|
|
attempts="${OPENCLAW_DOCKER_PULL_ATTEMPTS:-3}"
|
|
timeout_seconds="${OPENCLAW_DOCKER_PULL_TIMEOUT_SECONDS:-180}"
|
|
retry_delay_seconds="${OPENCLAW_DOCKER_PULL_RETRY_DELAY_SECONDS:-5}"
|
|
|
|
if ! [[ "$attempts" =~ ^[1-9][0-9]*$ ]]; then
|
|
echo "OPENCLAW_DOCKER_PULL_ATTEMPTS must be a positive integer, got: $attempts" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! [[ "$timeout_seconds" =~ ^[1-9][0-9]*$ ]]; then
|
|
echo "OPENCLAW_DOCKER_PULL_TIMEOUT_SECONDS must be a positive integer, got: $timeout_seconds" >&2
|
|
exit 2
|
|
fi
|
|
|
|
if ! [[ "$retry_delay_seconds" =~ ^[0-9]+$ ]]; then
|
|
echo "OPENCLAW_DOCKER_PULL_RETRY_DELAY_SECONDS must be a non-negative integer, got: $retry_delay_seconds" >&2
|
|
exit 2
|
|
fi
|
|
|
|
last_status=1
|
|
run_docker_pull() {
|
|
local timeout_bin
|
|
if ! timeout_bin="$(openclaw_host_timeout_bin)"; then
|
|
echo "timeout or gtimeout command not found; cannot bound Docker pull after ${timeout_seconds}s" >&2
|
|
return 127
|
|
fi
|
|
if "$timeout_bin" --kill-after=1s 1s true >/dev/null 2>&1; then
|
|
"$timeout_bin" --kill-after=30s "${timeout_seconds}s" docker pull "$image"
|
|
else
|
|
"$timeout_bin" "${timeout_seconds}s" docker pull "$image"
|
|
fi
|
|
}
|
|
|
|
for ((attempt = 1; attempt <= attempts; attempt++)); do
|
|
echo "==> Pull Docker image attempt ${attempt}/${attempts}: ${image}"
|
|
if run_docker_pull; then
|
|
exit 0
|
|
else
|
|
last_status="$?"
|
|
fi
|
|
echo "::warning::Docker pull failed or timed out after ${timeout_seconds}s: status=${last_status}" >&2
|
|
if [[ "$attempt" -lt "$attempts" && "$retry_delay_seconds" -gt 0 ]]; then
|
|
sleep "$retry_delay_seconds"
|
|
fi
|
|
done
|
|
|
|
exit "$last_status"
|