Skip to content

Commit 0f46d8f

Browse files
mercurial: take into account more cases of mercurial failures for retry. (#101)
Co-authored-by: Marco Castelluccio <[email protected]>
1 parent 038cc46 commit 0f46d8f

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

libmozevent/mercurial.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ async def run(self):
335335
# Find the repository from the diff and trigger the build on it
336336
repository = self.repositories.get(build.repo_phid)
337337
if repository is not None:
338-
339338
result = await self.handle_build(repository, build)
340339
if result:
341340
await self.bus.send(self.queue_phabricator, result)
@@ -454,7 +453,21 @@ async def handle_build(self, repository, build):
454453
if isinstance(error_log, bytes):
455454
error_log = error_log.decode("utf-8")
456455

457-
if "push failed on remote" in error_log.lower():
456+
def is_eligible_for_retry(error):
457+
"""
458+
Given a Mercurial error message, if it's an error likely due to a temporary connection problem, consider it as eligible for retry.
459+
"""
460+
eligible_errors = [
461+
"push failed on remote",
462+
"stream ended unexpectedly",
463+
"error: EOF occurred in violation of protocol",
464+
]
465+
for eligible_message in eligible_errors:
466+
if eligible_message in error_log:
467+
return True
468+
return False
469+
470+
if is_eligible_for_retry(error_log.lower()):
458471
build.retries += 1
459472
# Ensure try is opened
460473
await self.wait_try_available()

0 commit comments

Comments
 (0)