Skip to content

Commit b67d7f1

Browse files
committed
CI: Retry test-vector downloads on any failure
Signed-off-by: Matthias J. Kannwischer <matthias@zerorisc.com>
1 parent 02918ae commit b67d7f1

2 files changed

Lines changed: 14 additions & 10 deletions

File tree

test/acvp/acvp_client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626

2727
def download_file(url, dest, token):
28-
"""Fetch url to dest via the authenticated contents API, retrying on 429/403.
28+
"""Fetch url to dest via the authenticated contents API, retrying on failure.
2929
3030
Using api.github.com with a token raises the rate limit (per-user, not
3131
per-IP), which avoids throttling when many CI jobs share an egress IP.
@@ -39,11 +39,13 @@ def download_file(url, dest, token):
3939
with urllib.request.urlopen(req) as resp:
4040
dest.write_bytes(resp.read())
4141
return
42-
except urllib.error.HTTPError as e:
43-
if e.code not in (429, 403) or attempt == 4:
42+
except Exception as e:
43+
if attempt == 4:
4444
raise
45-
wait = min(int(e.headers.get("Retry-After") or 2**attempt), 60)
46-
print(f"Rate-limited ({e.code}); retrying in {wait}s", file=sys.stderr)
45+
wait = 2**attempt
46+
if isinstance(e, urllib.error.HTTPError):
47+
wait = min(int(e.headers.get("Retry-After") or wait), 60)
48+
print(f"Download failed ({e}); retrying in {wait}s", file=sys.stderr)
4749
time.sleep(wait)
4850

4951

test/wycheproof/wycheproof_client.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ def info(msg, **kwargs):
6464

6565

6666
def download_file(url, dest, token):
67-
"""Fetch url to dest via the authenticated contents API, retrying on 429/403.
67+
"""Fetch url to dest via the authenticated contents API, retrying on failure.
6868
6969
Using api.github.com with a token raises the rate limit (per-user, not
7070
per-IP), which avoids throttling when many CI jobs share an egress IP.
@@ -78,11 +78,13 @@ def download_file(url, dest, token):
7878
with urllib.request.urlopen(req) as resp:
7979
dest.write_bytes(resp.read())
8080
return
81-
except urllib.error.HTTPError as e:
82-
if e.code not in (429, 403) or attempt == 4:
81+
except Exception as e:
82+
if attempt == 4:
8383
raise
84-
wait = min(int(e.headers.get("Retry-After") or 2**attempt), 60)
85-
print(f"Rate-limited ({e.code}); retrying in {wait}s", file=sys.stderr)
84+
wait = 2**attempt
85+
if isinstance(e, urllib.error.HTTPError):
86+
wait = min(int(e.headers.get("Retry-After") or wait), 60)
87+
print(f"Download failed ({e}); retrying in {wait}s", file=sys.stderr)
8688
time.sleep(wait)
8789

8890

0 commit comments

Comments
 (0)