From 6b9557fc30339327f3124de15a074c1249c11c51 Mon Sep 17 00:00:00 2001 From: Zack Winter <3457246+zackwintermdb@users.noreply.github.com> Date: Wed, 12 Nov 2025 08:21:21 -0800 Subject: [PATCH] SERVER-113751 Wrap the Modules Linter in a Retry (#43844) GitOrigin-RevId: 0c79036a9d36ab44c5371f0523d69500a2721d92 --- modules_poc/merge_decls.py | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) diff --git a/modules_poc/merge_decls.py b/modules_poc/merge_decls.py index ab2a9443a0c..d68cbc4fa4a 100755 --- a/modules_poc/merge_decls.py +++ b/modules_poc/merge_decls.py @@ -130,15 +130,28 @@ def is_submodule_usage(decl_mod: str, *, usage_mod: str) -> bool: def get_paths(timer: Timer): - proc = subprocess.run( - ["bazel", "build", "--config=mod-scanner", "//src/mongo/..."], - text=True, # unnecessary since we don't use stdout, but makes the types match - cwd=REPO_ROOT, - check=False, - ) + # Retry the bazel build up to 3 times to handle transient failures + max_retries = 3 + + for attempt in range(1, max_retries + 1): + print(f"Bazel build attempt {attempt}/{max_retries}...") + proc = subprocess.run( + ["bazel", "build", "--config=mod-scanner", "//src/mongo/..."], + text=True, # unnecessary since we don't use stdout, but makes the types match + cwd=REPO_ROOT, + check=False, + ) + + if proc.returncode == 0: + break + + if attempt < max_retries: + print(f"Bazel build failed with exit code {proc.returncode}, " f"retrying...") + else: + print(f"Bazel build failed after {max_retries} attempts") + sys.exit(proc.returncode) + timer.mark("scanned sources") - if proc.returncode != 0: - sys.exit(proc.returncode) proc = subprocess.run( [