SERVER-113751 Wrap the Modules Linter in a Retry (#43844)

GitOrigin-RevId: 0c79036a9d36ab44c5371f0523d69500a2721d92
This commit is contained in:
Zack Winter 2025-11-12 08:21:21 -08:00 committed by MongoDB Bot
parent 4e931624a3
commit 6b9557fc30
1 changed files with 21 additions and 8 deletions

View File

@ -130,15 +130,28 @@ def is_submodule_usage(decl_mod: str, *, usage_mod: str) -> bool:
def get_paths(timer: Timer): def get_paths(timer: Timer):
proc = subprocess.run( # Retry the bazel build up to 3 times to handle transient failures
["bazel", "build", "--config=mod-scanner", "//src/mongo/..."], max_retries = 3
text=True, # unnecessary since we don't use stdout, but makes the types match
cwd=REPO_ROOT, for attempt in range(1, max_retries + 1):
check=False, 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") timer.mark("scanned sources")
if proc.returncode != 0:
sys.exit(proc.returncode)
proc = subprocess.run( proc = subprocess.run(
[ [