From 3aa0ca87c13aa7c0065534f257e9e1f8daf0c21c Mon Sep 17 00:00:00 2001 From: weiqingy Date: Thu, 9 Jul 2026 23:55:53 -0700 Subject: [PATCH] [ci] Retry Ollama install and propagate download failures The upstream Ollama installer probes for the .tar.zst release asset with a silent HEAD request and, on any failure of that probe, falls back to a .tgz that current releases no longer publish. A single transient network error therefore produces a hard 404 and fails the integration-test jobs before any test runs. Retry the install up to three times with a linear backoff. Reading the exit status after "curl ... | sh" also captured the status of sh rather than curl, so a failed download left sh reading empty stdin and exiting zero. The install step then "succeeded" with no Ollama present. Download the installer to a file and check curl directly, under set -euo pipefail. --- tools/start_ollama_server.sh | 31 ++++++++++++++++++++++++------- 1 file changed, 24 insertions(+), 7 deletions(-) diff --git a/tools/start_ollama_server.sh b/tools/start_ollama_server.sh index a80afcfc0..3c35a41c1 100644 --- a/tools/start_ollama_server.sh +++ b/tools/start_ollama_server.sh @@ -17,12 +17,29 @@ ################################################################################# # only works on linux +set -euo pipefail + os=$(uname -s) -echo $os +echo "$os" + +install_script=$(mktemp) +trap 'rm -f "$install_script"' EXIT + +# The upstream installer probes for the .tar.zst asset with a silent HEAD request, and on +# any failure of that probe falls back to a .tgz that current releases no longer publish. +# A single transient network error therefore turns into a hard 404, so retry the install. +attempts=3 +for attempt in $(seq 1 "$attempts"); do + if curl -fsSL https://ollama.com/install.sh -o "$install_script" && sh "$install_script"; then + exit 0 + fi + + if [ "$attempt" -lt "$attempts" ]; then + delay=$((attempt * 10)) + echo "ollama install attempt ${attempt}/${attempts} failed; retrying in ${delay}s" >&2 + sleep "$delay" + fi +done -curl -fsSL https://ollama.com/install.sh | sh -ret=$? -if [ "$ret" != "0" ] -then - exit $ret -fi \ No newline at end of file +echo "ollama install failed after ${attempts} attempts" >&2 +exit 1