Release: retry transient asset verification failures
Modular container CI / release-build (push) Successful in 20m45s
Signed modular release / publish (push) Successful in 18m32s
Nightly product integration / publish-nightly (push) Successful in 20m47s

This commit is contained in:
faumaray committed 2026-07-30 04:14:52 +03:00
1 parent 4f8a46b0c4
commit 9236dc844b
2 files changed
+59 -12

No files matched your search

+27 -12
View File
@@ -15,6 +15,7 @@ import re
import secrets
import stat
import sys
import time
from typing import Any, NoReturn
from urllib.error import HTTPError, URLError
from urllib.parse import quote, urlencode, urljoin, urlsplit
@@ -228,18 +229,32 @@ class GiteaApi:
):
fail(f"Gitea returned an untrusted asset URL: {download_url!r}")
request = Request(target, headers=self.headers, method="GET")
result = hashlib.sha256()
size = 0
try:
with self._opener.open(request, timeout=self._timeout_seconds) as response:
if response.status != 200:
fail(f"downloading an asset returned HTTP {response.status}")
while chunk := response.read(UPLOAD_CHUNK_BYTES):
size += len(chunk)
result.update(chunk)
except (HTTPError, OSError, URLError) as error:
fail(f"downloading an asset for verification failed: {error}")
return size, result.hexdigest()
for attempt in range(4):
result = hashlib.sha256()
size = 0
try:
with self._opener.open(
request, timeout=self._timeout_seconds
) as response:
if response.status != 200:
fail(
"downloading an asset returned "
f"HTTP {response.status}"
)
while chunk := response.read(UPLOAD_CHUNK_BYTES):
size += len(chunk)
result.update(chunk)
return size, result.hexdigest()
except HTTPError as error:
fail(f"downloading an asset for verification failed: {error}")
except (OSError, URLError) as error:
if attempt == 3:
fail(
"downloading an asset for verification failed "
f"after retries: {error}"
)
time.sleep(2**attempt)
raise AssertionError("unreachable")
def quote_owner(value: str) -> str: