Conversation
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Avoid logging and sleeping after the final failed attempt.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (1)
What changed in this PR
Adds retry handling to rustup-mirror for transient network failures.
Changes:
- Retries synchronization up to three times.
- Waits 60 seconds between attempts.
- Preserves failure status after all attempts fail.
| File | Description |
|---|---|
rustup.sh |
Adds retry handling around rustup-mirror. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| for i in $(seq 1 30); do | ||
| if /usr/local/cargo/bin/rustup-mirror -u "${BASE_URL}" -m "${TUNASYNC_WORKING_DIR}" --gc "${GC}"; then | ||
| ok=1 | ||
| break | ||
| fi | ||
| if [[ $i -lt 30 ]]; then | ||
| echo "rustup-mirror attempt $i failed, retrying in 10s" | ||
| sleep 10 |
|
Round-2 review item addressed: the retry policy is now named constants |
happyaron
left a comment
There was a problem hiding this comment.
rustup-mirror v0.12.0 (released today, includes jiegec/rustup-mirror@c0c6fcb) now retries transient download failures per file with exponential backoff instead of panicking, and exposes --retries (default 3). Since our image builds from crates.io max_stable_version, the next image rebuild picks this up.
Given that, could we drop the whole-run retry loop and instead pass the flag through, e.g. --retries "${RUSTUP_RETRIES:-3}", so NJU can raise it via env? A per-file retry avoids re-running the manifest walk and --gc up to 30 times, and doesn't multiply with the inner backoff. It also won't retry permanent errors 30 times.
If you still see failures on 0.12.0 that the per-file retry doesn't cover, happy to revisit the outer loop. In that case please make RETRY_ATTEMPTS/RETRY_DELAY env-overridable like RUSTUP_GC.
|
@happyaron Agreed and done in b57386a: the wrapper retry loop is dropped and the script now passes One deployment note from our side: the current production image still ships rustup-mirror 0.11.0 (no |
A single connection timeout to static.rust-lang.org fails the whole rustup sync run, and the job then shows as failed until the next scheduled attempt. We see this intermittently on mirror.nju.edu.cn, where direct connections to static.rust-lang.org time out. rustup-mirror 0.12.0 (jiegec/rustup-mirror@c0c6fcb) retries transient per-file download failures with exponential backoff and exposes --retries (default 3). Pass the flag through as --retries "${RUSTUP_RETRIES:-3}" so the policy is env-overridable like RUSTUP_GC. A wrapper retry loop around the whole rustup-mirror invocation was considered and dropped per review: per-file retry avoids re-running the manifest walk and --gc on every attempt, does not multiply with the inner backoff, and does not retry permanent errors N times. Deployment note: requires rustup-mirror >= 0.12.0 in the image (previous versions have no --retries flag).
b57386a to
dd924bd
Compare
|
Branch cleanup note: this branch has been squashed to a single commit, Review items → how they were addressed (all included in the current diff)
Deployment note (unchanged): the script now requires rustup-mirror ≥ 0.12.0 in the image; our production copy keeps the loop version until the image is rebuilt. Some earlier in-thread replies described intermediate states of the branch; please rely on the current diff and this summary. |

Summary
Pass
--retries "${RUSTUP_RETRIES:-3}"through torustup-mirror, enabling its built-in per-file retry for transient download failures.Why
A single connection timeout to
static.rust-lang.orgfails the whole rustup sync run, and the job then shows as failed until the next scheduled attempt. We see this intermittently on mirror.nju.edu.cn, where direct connections to static.rust-lang.org time out.rustup-mirror0.12.0 (jiegec/rustup-mirror@c0c6fcb) retries transient per-file download failures with exponential backoff and exposes--retries(default 3). Per-file retry is the right layer for this: a wrapper loop around the whole invocation would re-run the manifest walk and--gcon every attempt, multiply with the inner backoff, and retry permanent errors N times — so the wrapper loop this PR started with was dropped per review.Environment variables
RUSTUP_RETRIES3rustup-mirror --retries(
MIRROR_BASE_URLandRUSTUP_GCbehave as before.)Testing
Running in production on mirror.nju.edu.cn, where direct connections to static.rust-lang.org time out intermittently; with per-file retry the job completes reliably.
Deployment
Requires rustup-mirror ≥ 0.12.0 in the image — earlier versions have no
--retriesflag and would fail on the unknown option. The image builds from crates.iomax_stable_version, so the next image rebuild picks up 0.12.0.