Repository navigation
fix(compose): remove BuildKit snapshot race retry logic, for #8136 - #8637
Merged
Merged
Conversation
## The Issue - For ddev#8136 Docker 29 made the containerd image store the default storage driver, which exposed a race condition in containerd/BuildKit: when `docker-compose build` builds multiple services in parallel that share base layers, containerd's GC could delete a parent snapshot while a concurrent image export still depended on it, failing with: ``` failed to prepare extraction snapshot "extract-...": parent snapshot ... does not exist: not found ``` This showed up intermittently in DDEV's own CI (parallel `web`/`db` image builds) once GitHub Actions runners moved to Docker 29. ### History of the issue and its fixes - ddev#8136 opened tracking the CI failures against Docker 29 / containerd snapshotter, with links to the relevant upstream issues: - containerd/containerd#3787, containerd/containerd#2382, containerd/containerd#10835 (the snapshot-GC race itself) - containerd/containerd#10723 (upstream fix, cherry-picked to release/1.7 in #10763 and release/1.6 in #10764) - moby/buildkit#4024, moby/buildkit#6521 (BuildKit-level reports) - moby/moby#51665, containerd/nerdctl#3420 (downstream reports) - ddev#8142 (this repo) added a transient workaround: `composeBuild()` was extracted from the inline build logic in `Start()` and given a retry loop (`composeBuildMaxRetries = 3`) that detected the race by matching `"parent snapshot"` + `"does not exist"` in the build error output and retried the whole `docker-compose build` on match. - moby/buildkit#6558 landed the upstream fix for the race in BuildKit itself, and it shipped in a subsequent `moby/moby` bump of its `github.com/moby/buildkit` dependency. - Per the follow-up comment on ddev#8136, with the fix available upstream the retry logic "should be removed - everything is fixed upstream." ## How This PR Solves The Issue Removes the retry/detection logic added in ddev#8142, leaving `composeBuild()` as a single, plain build attempt: - Removed the `composeBuildMaxRetries` constant. - Removed the retry loop, the `"parent snapshot"` / `"does not exist"` error-text matching, and the associated warning/debug logging. - Kept the `composeBuild()` helper itself (a useful consolidation of the build call used by both the initial project build and the dirty-web-image `--no-cache` rebuild) and kept the compose-library based build call (`LoadComposeProject` / `svc.Build`) introduced later in ddev#8234, which is unrelated to the race workaround. No other files in the repository referenced the retry logic, the `composeBuildMaxRetries` constant, or the snapshot-race error text, so this is a self-contained change to `pkg/ddevapp/ddevapp.go`. ## Manual Testing Instructions 1. Build DDEV from this branch: `make` 2. Create and start a test project: ``` mkdir ~/tmp/test-8136 && cd ~/tmp/test-8136 ddev config --project-type=php --docroot=web ddev start -y ``` Confirm the project builds and starts normally (parallel `web` + `db` image build, no retry warnings). 3. Exercise the `--no-cache` dirty-web-image rebuild path and the `--no-cache` flag generally: ``` ddev start --no-cache ``` 4. `ddev delete -Oy` to clean up. ## Automated Testing Overview - `go build ./...`, `gofmt -l`, `go vet ./pkg/ddevapp/...`, and `make staticrequired` all pass. - `go test -v ./cmd/ddev/cmd/... -run TestCmdStartRestartNoCache` passes, exercising the `--no-cache` build path used by `composeBuild()`. - `go test -v ./pkg/ddevapp/... -run TestDdevStart` passes, exercising the normal parallel image build path. - No existing test referenced `composeBuild`, `composeBuildMaxRetries`, or the snapshot-race error text, so no test changes were needed. ## Release/Deployment Notes Pure removal of dead workaround code; no behavior change for the normal (non-racing) build path. If the upstream BuildKit fix has not actually propagated into the Docker/containerd versions users run, this could reintroduce intermittent build failures on Docker 29+; the issue history (moby/buildkit#6558 and the subsequent `moby/moby` dependency bump) indicates the fix is available upstream. Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_017uQBexzcjiKGsCGUcUiUeU
|
Download the artifacts for this pull request:
See Testing a PR. |
rfay
added a commit
to weitzman/ddev
that referenced
this pull request
Jul 31, 2026
ddev#8637) Co-authored-by: Claude Sonnet 5 <[email protected]>
nikmeiser
pushed a commit
to awslabs/automated-security-helper
that referenced
this pull request
Sep 19, 2026
The nerdctl leg of validate-container fails about one run in eighteen after the image has already been built. Measured across every ASH - Unified CI run since the leg landed: 136 passes, 3 failures of this shape, 5 further failures that were a branch defect failing podman and finch in the same runs. The build succeeds -- every stage completes, all 11 scanner tools verify on PATH, the manifest and config export, the tarball sends, #48 DONE. What fails is loading that tarball into containerd: level=fatal msg="apply layer error for \"...:ci\": failed to prepare extraction snapshot \"extract-...\": parent snapshot sha256:594f27ed... does not exist: not found" Traced rather than guessed. nerdctl asks buildkit whether its worker shares containerd's image store (pkg/cmd/builder/build.go, isImageSharable). The nerdctl-full bundle runs the oci worker, which does not, so nerdctl takes the else branch -- --output type=docker plus needsLoading -- and pipes the docker-format tarball through its own loadImage, which calls containerd's client Unpack. "apply layer error for" is that function's message and it lives in containerd's client/image.go, not in nerdctl and not in buildkit. Unpack walks layers with the per-layer rootfs.ApplyLayer, whose Stat-then-Prepare window does not hold the parent snapshot under a lease, so a concurrent GC pass can collect the parent between the two calls. This is containerd/nerdctl#3420, reported with the same string. moby/buildkit#6558 fixed the same race but only in buildkit's own exporter, for the type=image,unpack=true path; that fix is in the bundled buildkit 0.31.2, which is consistent with #48 DONE succeeding. Nothing has landed for the containerd-client side the tarball round trip routes through, so there is no version to bump to. Three mechanisms were separated rather than assumed: Not a deterministic defect in the action. Pull request 608's merge queue built this image five times from the same content -- four passed, one hit this error. Nothing in the repository distinguishes them. Not runner resource exhaustion. No ENOSPC or disk signal appears anywhere in the job log, and the timing rules it out: "sending tarball 3.7s done" at 20:10:26.1608 and the fatal at 20:10:26.2090, 48 ms later. A multi-gigabyte extraction cannot exhaust disk in 48 ms; it failed on the first Prepare, before writing layer data. The snapshot race in the buildkit-to-containerd handoff, which the docker-format tarball round trip selects. Established above. The retry only retries this error -- any other status exits immediately with its own code, so a real build break still fails fast on the first attempt. Retries deliberately drop --force, which is --no-cache: attempt 1 still proves a from-scratch build, and the retry then reuses the layers just built so it costs about a minute instead of seven and spends that minute re-running exactly the operation that raced. That works because BUILD_DATE_EPOCH, the one build-arg that changes per invocation, is consumed on the last line of the core stage rather than near its top. The half-imported image is cleared first so the retry rebuilds the snapshot chain instead of taking the same lease-skipping Stat shortcut over it. Configuring buildkitd with the containerd worker would skip the tarball entirely, and was rejected: it would have this gate test a configuration no nerdctl-full user has, so the default path would stop being measured while CI went green. No CI re-run of a job that hit this error exists, so "a retry succeeds" rests on the cross-run evidence above and on ddev/ddev#8142, which carried a max-3 retry on this same error text until ddev/ddev#8637 removed it once their path got its upstream fix. The ::warning:: on every retry is what closes that gap, making the race countable in the Actions UI. Verified: the extracted run block was exercised under the same shell flags GitHub uses for a composite bash step, with a stubbed ash, across six cases -- race-then-succeed, race on every attempt, a non-race failure, a clean first pass, a click UsageError exit 2, and an ANSI-prefixed race line. Each retried only when intended and preserved the build's own exit code. shellcheck -S style is clean. tests/unit/test_oci_runner_ci_coverage.py, which parses this action against the workflow matrix, passes 5/5, and the container build path tests pass 113/113.
nikmeiser
pushed a commit
to awslabs/automated-security-helper
that referenced
this pull request
Sep 19, 2026
The nerdctl leg of validate-container fails about one run in eighteen after the image has already been built. Measured across every ASH - Unified CI run since the leg landed: 136 passes, 3 failures of this shape, 5 further failures that were a branch defect failing podman and finch in the same runs. The build succeeds -- every stage completes, all 11 scanner tools verify on PATH, the manifest and config export, the tarball sends, #48 DONE. What fails is loading that tarball into containerd: level=fatal msg="apply layer error for \"...:ci\": failed to prepare extraction snapshot \"extract-...\": parent snapshot sha256:594f27ed... does not exist: not found" Traced rather than guessed. nerdctl asks buildkit whether its worker shares containerd's image store (pkg/cmd/builder/build.go, isImageSharable). The nerdctl-full bundle runs the oci worker, which does not, so nerdctl takes the else branch -- --output type=docker plus needsLoading -- and pipes the docker-format tarball through its own loadImage, which calls containerd's client Unpack. "apply layer error for" is that function's message and it lives in containerd's client/image.go, not in nerdctl and not in buildkit. Unpack walks layers with the per-layer rootfs.ApplyLayer, whose Stat-then-Prepare window does not hold the parent snapshot under a lease, so a concurrent GC pass can collect the parent between the two calls. This is containerd/nerdctl#3420, reported with the same string. moby/buildkit#6558 fixed the same race but only in buildkit's own exporter, for the type=image,unpack=true path; that fix is in the bundled buildkit 0.31.2, which is consistent with #48 DONE succeeding. Nothing has landed for the containerd-client side the tarball round trip routes through, so there is no version to bump to. Three mechanisms were separated rather than assumed: Not a deterministic defect in the action. Pull request 608's merge queue built this image five times from the same content -- four passed, one hit this error. Nothing in the repository distinguishes them. Not runner resource exhaustion. No ENOSPC or disk signal appears anywhere in the job log, and the timing rules it out: "sending tarball 3.7s done" at 20:10:26.1608 and the fatal at 20:10:26.2090, 48 ms later. A multi-gigabyte extraction cannot exhaust disk in 48 ms; it failed on the first Prepare, before writing layer data. The snapshot race in the buildkit-to-containerd handoff, which the docker-format tarball round trip selects. Established above. The retry only retries this error -- any other status exits immediately with its own code, so a real build break still fails fast on the first attempt. Retries deliberately drop --force, which is --no-cache: attempt 1 still proves a from-scratch build, and the retry then reuses the layers just built so it costs about a minute instead of seven and spends that minute re-running exactly the operation that raced. That works because BUILD_DATE_EPOCH, the one build-arg that changes per invocation, is consumed on the last line of the core stage rather than near its top. The half-imported image is cleared first so the retry rebuilds the snapshot chain instead of taking the same lease-skipping Stat shortcut over it. Configuring buildkitd with the containerd worker would skip the tarball entirely, and was rejected: it would have this gate test a configuration no nerdctl-full user has, so the default path would stop being measured while CI went green. No CI re-run of a job that hit this error exists, so "a retry succeeds" rests on the cross-run evidence above and on ddev/ddev#8142, which carried a max-3 retry on this same error text until ddev/ddev#8637 removed it once their path got its upstream fix. The ::warning:: on every retry is what closes that gap, making the race countable in the Actions UI. Verified: the extracted run block was exercised under the same shell flags GitHub uses for a composite bash step, with a stubbed ash, across six cases -- race-then-succeed, race on every attempt, a non-race failure, a clean first pass, a click UsageError exit 2, and an ANSI-prefixed race line. Each retried only when intended and preserved the build's own exit code. shellcheck -S style is clean. tests/unit/test_oci_runner_ci_coverage.py, which parses this action against the workflow matrix, passes 5/5, and the container build path tests pass 113/113.
nikmeiser
pushed a commit
to awslabs/automated-security-helper
that referenced
this pull request
Sep 19, 2026
The nerdctl leg of validate-container fails about one run in eighteen after the image has already been built. Measured across every ASH - Unified CI run since the leg landed: 136 passes, 3 failures of this shape, 5 further failures that were a branch defect failing podman and finch in the same runs. The build succeeds -- every stage completes, all 11 scanner tools verify on PATH, the manifest and config export, the tarball sends, #48 DONE. What fails is loading that tarball into containerd: level=fatal msg="apply layer error for \"...:ci\": failed to prepare extraction snapshot \"extract-...\": parent snapshot sha256:594f27ed... does not exist: not found" Traced rather than guessed. nerdctl asks buildkit whether its worker shares containerd's image store (pkg/cmd/builder/build.go, isImageSharable). The nerdctl-full bundle runs the oci worker, which does not, so nerdctl takes the else branch -- --output type=docker plus needsLoading -- and pipes the docker-format tarball through its own loadImage, which calls containerd's client Unpack. "apply layer error for" is that function's message and it lives in containerd's client/image.go, not in nerdctl and not in buildkit. Unpack walks layers with the per-layer rootfs.ApplyLayer, whose Stat-then-Prepare window does not hold the parent snapshot under a lease, so a concurrent GC pass can collect the parent between the two calls. This is containerd/nerdctl#3420, reported with the same string. moby/buildkit#6558 fixed the same race but only in buildkit's own exporter, for the type=image,unpack=true path; that fix is in the bundled buildkit 0.31.2, which is consistent with #48 DONE succeeding. Nothing has landed for the containerd-client side the tarball round trip routes through, so there is no version to bump to. Three mechanisms were separated rather than assumed: Not a deterministic defect in the action. Pull request 608's merge queue built this image five times from the same content -- four passed, one hit this error. Nothing in the repository distinguishes them. Not runner resource exhaustion. No ENOSPC or disk signal appears anywhere in the job log, and the timing rules it out: "sending tarball 3.7s done" at 20:10:26.1608 and the fatal at 20:10:26.2090, 48 ms later. A multi-gigabyte extraction cannot exhaust disk in 48 ms; it failed on the first Prepare, before writing layer data. The snapshot race in the buildkit-to-containerd handoff, which the docker-format tarball round trip selects. Established above. The retry only retries this error -- any other status exits immediately with its own code, so a real build break still fails fast on the first attempt. Retries deliberately drop --force, which is --no-cache: attempt 1 still proves a from-scratch build, and the retry then reuses the layers just built so it costs about a minute instead of seven and spends that minute re-running exactly the operation that raced. That works because BUILD_DATE_EPOCH, the one build-arg that changes per invocation, is consumed on the last line of the core stage rather than near its top. The half-imported image is cleared first so the retry rebuilds the snapshot chain instead of taking the same lease-skipping Stat shortcut over it. Configuring buildkitd with the containerd worker would skip the tarball entirely, and was rejected: it would have this gate test a configuration no nerdctl-full user has, so the default path would stop being measured while CI went green. No CI re-run of a job that hit this error exists, so "a retry succeeds" rests on the cross-run evidence above and on ddev/ddev#8142, which carried a max-3 retry on this same error text until ddev/ddev#8637 removed it once their path got its upstream fix. The ::warning:: on every retry is what closes that gap, making the race countable in the Actions UI. Verified: the extracted run block was exercised under the same shell flags GitHub uses for a composite bash step, with a stubbed ash, across six cases -- race-then-succeed, race on every attempt, a non-race failure, a clean first pass, a click UsageError exit 2, and an ANSI-prefixed race line. Each retried only when intended and preserved the build's own exit code. shellcheck -S style is clean. tests/unit/test_oci_runner_ci_coverage.py, which parses this action against the workflow matrix, passes 5/5, and the container build path tests pass 113/113.
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.
The Issue
failed to prepare extraction snapshot "...": parent snapshot ... does not exist: not found#8136Docker 29 made the containerd image store the default storage driver,
which exposed a race condition in containerd/BuildKit: when
docker-compose buildbuilds multiple services in parallel that sharebase layers, containerd's GC could delete a parent snapshot while a
concurrent image export still depended on it, failing with:
This showed up intermittently in DDEV's own CI (parallel
web/dbimage builds) once GitHub Actions runners moved to Docker 29.
History of the issue and its fixes
failed to prepare extraction snapshot "...": parent snapshot ... does not exist: not found#8136 opened tracking the CI failures against Docker 29 / containerdsnapshotter, with links to the relevant upstream issues:
nerdctl pull:failed to prepare extraction snapshot, parent snapshot does not exist(1.7.23 regression?) containerd/containerd#10835 (the snapshot-GC race itself)release/1.7 in #10763 and release/1.6 in #10764)
composeBuild()was extractedfrom the inline build logic in
Start()and given a retry loop(
composeBuildMaxRetries = 3) that detected the race by matching"parent snapshot"+"does not exist"in the build error outputand retried the whole
docker-compose buildon match.itself, and it shipped in a subsequent
moby/mobybump of itsgithub.com/moby/buildkitdependency.failed to prepare extraction snapshot "...": parent snapshot ... does not exist: not found#8136, with the fix available upstreamthe retry logic "should be removed - everything is fixed upstream."
How This PR Solves The Issue
Removes the retry/detection logic added in #8142, leaving
composeBuild()as a single, plain build attempt:composeBuildMaxRetriesconstant."parent snapshot"/"does not exist"error-text matching, and the associated warning/debug logging.
composeBuild()helper itself (a useful consolidation ofthe build call used by both the initial project build and the
dirty-web-image
--no-cacherebuild) and kept the compose-librarybased build call (
LoadComposeProject/svc.Build) introducedlater in feat: use docker-compose library, optionally download docker-buildx, fixes #7915, for #8295 #8234, which is unrelated to the race workaround.
No other files in the repository referenced the retry logic, the
composeBuildMaxRetriesconstant, or the snapshot-race error text, sothis is a self-contained change to
pkg/ddevapp/ddevapp.go.Manual Testing Instructions
I think if this passes normal testing it should be OK.
Automated Testing Overview
Should still do the same things it did before.