Skip to content

Commit abfab52

Browse files
committed
fix: retry .taskcluster.yml fetches on 404
We get this intermittently for whatever reason, and it's constantly busting deployments.
1 parent cfa0a5c commit abfab52

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed

src/ciadmin/generate/in_tree_actions.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import hashlib
1111
import textwrap
1212

13+
import aiohttp
1314
import iso8601
1415
import yaml
1516
from taskcluster import optionsFromEnvironment
@@ -66,10 +67,17 @@ def hash(val):
6667
# TODO: perhaps we should do this for partly globbed branches,
6768
# eg: release* ?
6869
# we'd have to fetch that list from the server to do that
69-
if "*" not in b:
70+
if "*" not in b and "*" not in p.repo:
7071

7172
def process(project, branch_name, task):
72-
tcy = task.result()
73+
try:
74+
tcy = task.result()
75+
except aiohttp.ClientResponseError as e:
76+
# .taskcluster.yml doesn't exist. This can happen if
77+
# a project owner moves it away to disable Taskcluster.
78+
if e.status == 404:
79+
return
80+
raise e
7381

7482
# some ancient projects have no .taskcluster.yml
7583
if not tcy:
@@ -102,7 +110,7 @@ def process(project, branch_name, task):
102110
future.add_done_callback(functools.partial(process, p, b))
103111
futures.append(future)
104112

105-
await asyncio.gather(*futures)
113+
await asyncio.gather(*futures, return_exceptions=True)
106114
return rv
107115

108116

src/ciadmin/generate/tcyml.py

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
from asyncio import Lock
88

9-
import aiohttp
9+
from aiohttp_retry import ExponentialRetry, RetryClient
1010
from tcadmin.util.sessions import aiohttp_session
1111

1212
_cache = {}
@@ -49,15 +49,16 @@ async def get(repo_path, repo_type="hg", revision=None, default_branch=None):
4949
if repo_path in _cache:
5050
return _cache[repo_path]
5151

52-
try:
53-
async with aiohttp_session().get(url) as response:
54-
response.raise_for_status()
55-
result = await response.read()
56-
except aiohttp.ClientResponseError as e:
57-
if e.status == 404:
58-
result = None
59-
else:
60-
raise e
52+
client = RetryClient(
53+
client_session=aiohttp_session(),
54+
# Despite only setting 404 here, 5xx statuses will still be retried
55+
# for. See https://github.com/inyutin/aiohttp_retry?tab=readme-ov-file
56+
# for details.
57+
retry_options=ExponentialRetry(attempts=5, statuses={404}),
58+
)
59+
async with client.get(url) as response:
60+
response.raise_for_status()
61+
result = await response.read()
6162

6263
_cache[repo_path] = result
6364
return _cache[repo_path]

0 commit comments

Comments
 (0)