Repository navigation
fix(sandbox): a VM build or pull that fails, other than in a RUN command, runs once more - #179
Merged
Merged
Conversation
…and, runs once more A registry's wrong answer can pass, including a 404 for a blob it holds, which Docker's own download retries don't cover, and one such answer failed a whole deploy. A VM's docker build now runs once more, 5 s later, unless a RUN command failed (either builder's message), and docker pull by name runs once more on any failure; the amd64 fallback is unchanged. Only the build reruns, not the context download. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…er wrote it The warning took the formatted error's last line, which is an empty stderr: label when Docker wrote only to stdout; it now takes the last line that says something. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
A VM builds an image from its build context with one
docker buildand pulls one by name with onedocker pull. One wrong answer from a registry failed the whole deploy, as in this build on modal_vm:More than 50 other builds of the same image in that run succeeded, so the answer was transient. It's a 404, which dockerd's own download retries don't cover. Since infra images are rebuilt on a VM of another platform, a run from an arm64 Mac makes about five builds per modal_vm deploy, each pulling its base images.
The change
VmSandbox._build_imageruns thedocker buildonce more, 5 s later, unless a RUN command failed. Both builders say so in fixed words: the legacy builder (a VM with no buildx, such as modal_vm's) says "returned a non-zero code", and BuildKit says "did not complete successfully". So a failed fetch of a base image, aCOPY --fromimage or a# syntax=frontend is retried on either builder, and a failing RUN fails once, with its output. Only the build reruns: the context is extracted in its own step first._pullrunsdocker pullonce more, 5 s later, on any failure. The linux/amd64 fallback for "no matching manifest" is unchanged, and a fallback pull is retried the same way.Why match RUN failures rather than transient errors: the failure above is a "not found", and a list of transient-looking errors would have treated it as permanent. A broken Dockerfile or a COPY of a missing file wastes one retry, a few seconds.
Testing
Live check
Run on Docker 29.5.3 (macOS arm64, Rancher Desktop), using the real
LocalSandboxProvider,load_docker_imagesandpull_images. Aregistry:2sits behind a proxy that answers 404 to the first blob fetch of each image, as the mirror did. Each image is unique and pushed only to the registry, so Docker has to fetch it.DOCKER_BUILDKIT=0), base image's first blob fetch 404sdocker pullby name, first blob fetch 404sRUN … && false, on each builderWith a 404 on every blob's first fetch, two transient failures in a row, the legacy build fails after its one retry, as intended.
Chaos
15 minutes on each of three randomly picked EC2 VMs: Ubuntu 22.04 arm64 (Docker 29.1.3, no buildx, so the legacy builder) and Ubuntu 24.04 arm64 and amd64 (buildx 0.30.1).
LocalSandboxbuild or pull, run 2–3 at a time.docker build/docker pullwas killed.returned a non-zero codeand wasn't retried;Limits
pip install, say) isn't retried.🤖 Generated with Claude Code


Confidence Score: 5/5
The PR appears safe to merge; the previous warning issue is fixed.Summary
VM image builds and pulls retry once after five seconds. Builds that fail in a RUN command are not retried.
RUNcommand.Diagram
%%{init: {'theme': 'neutral'}}%% flowchart TD A[Build or pull image] --> B{Succeeded?} B -->|Yes| C[Continue] B -->|No| D{Build RUN failed?} D -->|Yes| E[Raise error] D -->|No| F[Log last nonempty output line] F --> G[Wait five seconds] G --> H[Retry once] H --> I{Succeeded?} I -->|Yes| C I -->|No| EReviews (2) · Last reviewed commit: "fix(sandbox): a retried build's warning ..." · Reviewed by Greptile