Skip to content

Commit dddb4d3

Browse files
Staged builds: retry when the channel index lags behind uploads (#22)
prefix.dev's sharded repodata, which rattler reads, lists a new upload a few minutes after repodata.json does. A stage starting right after the previous one uploaded then fails with "No candidates were found" for a package that is on the channel (lyrical linux-64, plansys2_pddl_parser). build-ci now retries that failure twice, 3 minutes apart; other failures aren't retried. Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
1 parent adceb96 commit dddb4d3

1 file changed

Lines changed: 28 additions & 1 deletion

File tree

‎tools/robostack.py‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,33 @@ def run(cmd: list[str], cwd: Path) -> int:
6262
return subprocess.run(cmd, cwd=cwd).returncode
6363

6464

65+
# prefix.dev's sharded repodata (what rattler reads) lists a new upload a few minutes
66+
# after repodata.json does, so a stage that starts right after the previous one
67+
# uploaded can find no candidates for a package that is on the channel.
68+
INDEX_LAG_MESSAGE = b"No candidates were found"
69+
INDEX_LAG_RETRIES = 2
70+
INDEX_LAG_WAIT = 180
71+
72+
73+
def run_build(cmd: list[str], cwd: Path) -> int:
74+
"""run() for staged builds: retry when the solver misses a package, waiting for
75+
the channel's index to catch up with the previous stage's uploads."""
76+
for attempt in range(INDEX_LAG_RETRIES + 1):
77+
print("+", " ".join(cmd), f" (in {cwd.relative_to(ROOT)})", flush=True)
78+
missing = False
79+
with subprocess.Popen(cmd, cwd=cwd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) as proc:
80+
for line in proc.stdout:
81+
sys.stdout.buffer.write(line)
82+
sys.stdout.buffer.flush()
83+
missing = missing or INDEX_LAG_MESSAGE in line
84+
if proc.returncode == 0 or not missing or attempt == INDEX_LAG_RETRIES:
85+
return proc.returncode
86+
print(f"A dependency was not found; waiting {INDEX_LAG_WAIT} s for the channel index "
87+
f"(retry {attempt + 1} of {INDEX_LAG_RETRIES})", file=sys.stderr, flush=True)
88+
time.sleep(INDEX_LAG_WAIT)
89+
return proc.returncode
90+
91+
6592
# --------------------------------------------------------------------------- #
6693
# generated files
6794
# --------------------------------------------------------------------------- #
@@ -266,7 +293,7 @@ def task(distro: str, name: str, args: list[str]) -> int:
266293
if name == "build":
267294
return run(rattler_build(distro, ["--recipe-dir", "./recipes", *args]), w)
268295
if name == "build-ci": # used by .scripts/build_unix.sh / build_win.bat
269-
return run(rattler_build(distro, args, skip_existing=False), w)
296+
return run_build(rattler_build(distro, args, skip_existing=False), w)
270297
if name == "build-one":
271298
pkg = args[0] if args else "ros2-ros-workspace"
272299
for patch in (d / "patch").glob(f"{pkg}.*patch"):

0 commit comments

Comments
 (0)