fix(agent): retry transient release metadata failures
Heimdall Gitea / Detect CI scope (pull_request) Successful in 5s
Heimdall Gitea / Build and tests (pull_request) Successful in 25m52s
Heimdall Gitea / Publish versioned release (pull_request) Skipped
Heimdall Gitea / Build and scan server image (pull_request) Successful in 8m34s
Heimdall Gitea / Build and scan agent image (pull_request) Successful in 14m24s
Heimdall Gitea / Publish Docker Hub latest tags (pull_request) Skipped
Heimdall Gitea / Build and scan NVIDIA Agent image (pull_request) Successful in 22m38s
Heimdall Gitea / CI policy (pull_request) Successful in 1s

This commit is contained in:
arnaud.dartois committed 2026-11-06 13:57:15 +01:00
1 parent 208732b4d9
commit 4e2ff8c2b6
4 files changed
+84 -3

No files matched your search

+21 -1
View File
@@ -41,7 +41,27 @@ fi
"$DOTNET_BIN" --list-runtimes | grep -q '^Microsoft.AspNetCore.App 10\.' || {
echo 'A compatible ASP.NET Core 10 runtime is required' >&2; exit 1;
}
curl -fsS "$CENTRAL_URL/api/updates/latest" -o "$TMP_DIR/release.json" || { echo "Failed to fetch release" >&2; exit 1; }
RELEASE_METADATA_URL="$CENTRAL_URL/api/updates/latest"
for attempt in 1 2 3; do
CURL_PROTOCOL=https
[[ "$CENTRAL_URL" == https://* ]] || CURL_PROTOCOL=http
HTTP_STATUS=$(curl -sS --proto "$CURL_PROTOCOL" \
--connect-timeout 10 --max-time 30 \
-w '%{http_code}' "$RELEASE_METADATA_URL" -o "$TMP_DIR/release.json") && CURL_STATUS=0 || CURL_STATUS=$?
if [[ "$CURL_STATUS" -eq 0 && "$HTTP_STATUS" =~ ^2[0-9][0-9]$ ]]; then
break
fi
if [[ "$CURL_STATUS" -ne 0 && "$HTTP_STATUS" == 000 ]] || [[ "$HTTP_STATUS" =~ ^(408|425|429|5[0-9][0-9])$ ]]; then
if [[ "$attempt" -lt 3 ]]; then
delay=$((attempt * 2))
echo "Release metadata request failed temporarily (attempt $attempt/3); retrying in ${delay}s." >&2
sleep "$delay"
continue
fi
fi
echo "Failed to fetch release metadata from Central (HTTP ${HTTP_STATUS:-000}; curl exit ${CURL_STATUS})." >&2
exit 1
done
if [[ -z "$UPDATE_PUBLIC_KEY" ]]; then
jq -er '.updatePublicKeyPem | select(type == "string" and length > 0 and length <= 4096)' "$TMP_DIR/release.json" > "$TMP_DIR/update-public-key.pem" || {
echo 'Central release metadata has no valid publisher public key' >&2; exit 1;