Repository navigation
fix(compose): add retry logic for docker-compose build BuildKit snapshot race condition, for #8136 - #8142
Conversation
b4796b7 to
e4c204b
Compare
|
On the first round with this one (before rebase and fix static linting) there didn't seem to be any failures of the familiar type. |
|
Download the artifacts for this pull request:
See Testing a PR. |
|
This appears to be a successful mitigation. The snapshot problem did not appear. |
|
Results can be examined by searching build output for "BuildKit snapshot race condition detected" We see it show up, and get fixed by retry. https://github.com/ddev/ddev/actions/runs/22013083087/job/63610406535?pr=8142#step:13:8658 Latest failures on macOS seem to be a result of HEAD commit, see |
| Progress: true, | ||
| Timeout: time.Hour * 1, | ||
| }) | ||
| _, err = app.composeBuild("web", "--no-cache") |
There was a problem hiding this comment.
Hmm, this looks wrong in general. Why web only and why --no-cache ?
There was a problem hiding this comment.
This preserves the original DDEV behavior from before the refactoring. The code checks if the web image has stderr output (indicating it's "dirty" - has build warnings/errors) and if so, rebuilds just the web service with --no-cache to ensure a clean build. This was already in the original code at lines 1778-1792 of the pre-refactor version.
… condition, fixes #8136 Co-authored-by: rfay <[email protected]>
Co-Authored-By: Claude Opus 4.6 <[email protected]>
…othesis comment Co-authored-by: rfay <[email protected]>
b33adcf to
1965566
Compare
Two defects in the retry added by the previous commit, both found by review. The error match was two independent greps over the whole build output, one for "parent snapshot" and one for "does not exist" -- the same shape ddev/ddev#8142 used. Two unrelated lines satisfy it. Measured against a fixture printing "reusing parent snapshot layer cache" and, two lines later, "requirements.txt: does not exist", the two-grep form classified a genuine build break as the race, spent both retries on it, and reported "this is containerd/nerdctl#3420, not an ASH defect" about a real ASH defect. The exit code survived so the job still failed, but the log told the next reader the wrong cause. Now one line must carry both. containerd emits the whole thing as a single message -- client/image.go:349 wraps the snapshotter error as `apply layer error for %q: %w` -- and `parent snapshot <digest> does not exist` appears exactly once, unsplit, in each of the three observed failures. Controls both ways: the regex still matches all three real race logs, and does not match any of the five branch-defect logs or the split-phrase fixture. `apply layer error` is deliberately not also required, being nerdctl's wrapper rather than the race. The stated rate was wrong. "One run in eighteen" is 8 failures over 144 terminal outcomes -- every failure of both modes -- sitting in the same comment that correctly separates them into 3 race and 5 branch defect. The race rate is 3 in 139, one run in forty-six, and the comment now shows the arithmetic: 168 runs swept, 158 producing a nerdctl job (7 produced none, 3 returned HTTP 502 on every retry and are counted unknown rather than as passes, and 158 + 7 + 3 = 168), splitting 136 success, 8 failure, 14 cancelled; 144 terminal, less the 5 branch-defect failures that also failed podman and finch in exactly those same five runs, leaves 3 in 139. Verified: seven cases against the extracted run block under the composite step's own shell flags -- race then succeed, race throughout, non-race failure, clean pass, click UsageError exit 2, ANSI-prefixed race line, and the split-phrase break that the old form got wrong. shellcheck -S style clean; test_oci_runner_ci_coverage.py 5 passed.
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.
Two defects in the retry added by the previous commit, both found by review. The error match was two independent greps over the whole build output, one for "parent snapshot" and one for "does not exist" -- the same shape ddev/ddev#8142 used. Two unrelated lines satisfy it. Measured against a fixture printing "reusing parent snapshot layer cache" and, two lines later, "requirements.txt: does not exist", the two-grep form classified a genuine build break as the race, spent both retries on it, and reported "this is containerd/nerdctl#3420, not an ASH defect" about a real ASH defect. The exit code survived so the job still failed, but the log told the next reader the wrong cause. Now one line must carry both. containerd emits the whole thing as a single message -- client/image.go:349 wraps the snapshotter error as `apply layer error for %q: %w` -- and `parent snapshot <digest> does not exist` appears exactly once, unsplit, in each of the three observed failures. Controls both ways: the regex still matches all three real race logs, and does not match any of the five branch-defect logs or the split-phrase fixture. `apply layer error` is deliberately not also required, being nerdctl's wrapper rather than the race. The stated rate was wrong. "One run in eighteen" is 8 failures over 144 terminal outcomes -- every failure of both modes -- sitting in the same comment that correctly separates them into 3 race and 5 branch defect. The race rate is 3 in 139, one run in forty-six, and the comment now shows the arithmetic: 168 runs swept, 158 producing a nerdctl job (7 produced none, 3 returned HTTP 502 on every retry and are counted unknown rather than as passes, and 158 + 7 + 3 = 168), splitting 136 success, 8 failure, 14 cancelled; 144 terminal, less the 5 branch-defect failures that also failed podman and finch in exactly those same five runs, leaves 3 in 139. Verified: seven cases against the extracted run block under the composite step's own shell flags -- race then succeed, race throughout, non-race failure, clean pass, click UsageError exit 2, ANSI-prefixed race line, and the split-phrase break that the old form got wrong. shellcheck -S style clean; test_oci_runner_ci_coverage.py 5 passed.
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.
Two defects in the retry added by the previous commit, both found by review. The error match was two independent greps over the whole build output, one for "parent snapshot" and one for "does not exist" -- the same shape ddev/ddev#8142 used. Two unrelated lines satisfy it. Measured against a fixture printing "reusing parent snapshot layer cache" and, two lines later, "requirements.txt: does not exist", the two-grep form classified a genuine build break as the race, spent both retries on it, and reported "this is containerd/nerdctl#3420, not an ASH defect" about a real ASH defect. The exit code survived so the job still failed, but the log told the next reader the wrong cause. Now one line must carry both. containerd emits the whole thing as a single message -- client/image.go:349 wraps the snapshotter error as `apply layer error for %q: %w` -- and `parent snapshot <digest> does not exist` appears exactly once, unsplit, in each of the three observed failures. Controls both ways: the regex still matches all three real race logs, and does not match any of the five branch-defect logs or the split-phrase fixture. `apply layer error` is deliberately not also required, being nerdctl's wrapper rather than the race. The stated rate was wrong. "One run in eighteen" is 8 failures over 144 terminal outcomes -- every failure of both modes -- sitting in the same comment that correctly separates them into 3 race and 5 branch defect. The race rate is 3 in 139, one run in forty-six, and the comment now shows the arithmetic: 168 runs swept, 158 producing a nerdctl job (7 produced none, 3 returned HTTP 502 on every retry and are counted unknown rather than as passes, and 158 + 7 + 3 = 168), splitting 136 success, 8 failure, 14 cancelled; 144 terminal, less the 5 branch-defect failures that also failed podman and finch in exactly those same five runs, leaves 3 in 139. Verified: seven cases against the extracted run block under the composite step's own shell flags -- race then succeed, race throughout, non-race failure, clean pass, click UsageError exit 2, ANSI-prefixed race line, and the split-phrase break that the old form got wrong. shellcheck -S style clean; test_oci_runner_ci_coverage.py 5 passed.
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.
Two defects in the retry added by the previous commit, both found by review. The error match was two independent greps over the whole build output, one for "parent snapshot" and one for "does not exist" -- the same shape ddev/ddev#8142 used. Two unrelated lines satisfy it. Measured against a fixture printing "reusing parent snapshot layer cache" and, two lines later, "requirements.txt: does not exist", the two-grep form classified a genuine build break as the race, spent both retries on it, and reported "this is containerd/nerdctl#3420, not an ASH defect" about a real ASH defect. The exit code survived so the job still failed, but the log told the next reader the wrong cause. Now one line must carry both. containerd emits the whole thing as a single message -- client/image.go:349 wraps the snapshotter error as `apply layer error for %q: %w` -- and `parent snapshot <digest> does not exist` appears exactly once, unsplit, in each of the three observed failures. Controls both ways: the regex still matches all three real race logs, and does not match any of the five branch-defect logs or the split-phrase fixture. `apply layer error` is deliberately not also required, being nerdctl's wrapper rather than the race. The stated rate was wrong. "One run in eighteen" is 8 failures over 144 terminal outcomes -- every failure of both modes -- sitting in the same comment that correctly separates them into 3 race and 5 branch defect. The race rate is 3 in 139, one run in forty-six, and the comment now shows the arithmetic: 168 runs swept, 158 producing a nerdctl job (7 produced none, 3 returned HTTP 502 on every retry and are counted unknown rather than as passes, and 158 + 7 + 3 = 168), splitting 136 success, 8 failure, 14 cancelled; 144 terminal, less the 5 branch-defect failures that also failed podman and finch in exactly those same five runs, leaves 3 in 139. Verified: seven cases against the extracted run block under the composite step's own shell flags -- race then succeed, race throughout, non-race failure, clean pass, click UsageError exit 2, ANSI-prefixed race line, and the split-phrase break that the old form got wrong. shellcheck -S style clean; test_oci_runner_ci_coverage.py 5 passed.
Two defects in the retry added by the previous commit, both found by review. The error match was two independent greps over the whole build output, one for "parent snapshot" and one for "does not exist" -- the same shape ddev/ddev#8142 used. Two unrelated lines satisfy it. Measured against a fixture printing "reusing parent snapshot layer cache" and, two lines later, "requirements.txt: does not exist", the two-grep form classified a genuine build break as the race, spent both retries on it, and reported "this is containerd/nerdctl#3420, not an ASH defect" about a real ASH defect. The exit code survived so the job still failed, but the log told the next reader the wrong cause. Now one line must carry both. containerd emits the whole thing as a single message -- client/image.go:349 wraps the snapshotter error as `apply layer error for %q: %w` -- and `parent snapshot <digest> does not exist` appears exactly once, unsplit, in each of the three observed failures. Controls both ways: the regex still matches all three real race logs, and does not match any of the five branch-defect logs or the split-phrase fixture. `apply layer error` is deliberately not also required, being nerdctl's wrapper rather than the race. The stated rate was wrong. "One run in eighteen" is 8 failures over 144 terminal outcomes -- every failure of both modes -- sitting in the same comment that correctly separates them into 3 race and 5 branch defect. The race rate is 3 in 139, one run in forty-six, and the comment now shows the arithmetic: 168 runs swept, 158 producing a nerdctl job (7 produced none, 3 returned HTTP 502 on every retry and are counted unknown rather than as passes, and 158 + 7 + 3 = 168), splitting 136 success, 8 failure, 14 cancelled; 144 terminal, less the 5 branch-defect failures that also failed podman and finch in exactly those same five runs, leaves 3 in 139. Verified: seven cases against the extracted run block under the composite step's own shell flags -- race then succeed, race throughout, non-race failure, clean pass, click UsageError exit 2, ANSI-prefixed race line, and the split-phrase break that the old form got wrong. shellcheck -S style clean; test_oci_runner_ci_coverage.py 5 passed.
…d retry the nerdctl snapshot GC race (#631) * fix(ci): stop the container build legs from scanning the checkout The three `ash build-image` steps in validate-container ran as plain `run:` steps with no `--no-run`, so each one built the image and then scanned this repository, and the step exited with that scan's status. `ash build-image` defaults to build-and-scan: cli/image.py passes `run=not no_run` and never passes `source_dir`, so run_ash_scan.py falls back to `Path.cwd()`, which under a composite action is the checkout. Actionable findings anywhere in the tree exit 2 and failed a step whose job is to prove the Dockerfile still builds. All three legs get the flag, not just podman and finch. The nerdctl leg is the same shape and would fail the same way the moment the repository holds a finding. Removing the scan loses no coverage, because the build steps were never what proved the image can scan. The `Scan with the built image` step below them is that, deliberately: it targets /tmp/ash-selftest, which holds one print statement, so its comment argues at length that only exit 0 is acceptable. A checkout scan cannot be held to that bar since its status depends on what happens to be committed, which is exactly why it made the build legs fail for unrelated reasons. That step is untouched here. Added a mirrored assertion next to the existing `Assert this runtime has a scan leg` guard. Same reasoning as that one: a build step that loses `--no-run` should fail loudly rather than quietly go back to scanning the checkout. It reads only `run:` lines, since the prose in this file names `ash build-image` too and a check that flagged comments would fail on every commit. Verified statically; the container legs need an OCI runtime this was not run on. `--no-run` reaches the skip: cli/image.py:164 sends `run=False` through run_ash_scan.py:862 to `if run:` in run_ash_container.py:1059, whose else path returns returncode 0 without assembling a run command. The new guard was controlled both ways - it passes on this tree, and fails naming the offending line when a `--no-run` is deleted. * fix: skip unparseable files instead of raising in get_model_from_template `load_yaml(f.read())` ran above the `try` that wraps `model_validate`, so the function had no way to answer "this is not a CloudFormation template" for a file YAML cannot parse -- it raised instead. Both are ordinary inputs, not edge cases, because callers scan whatever a repository happens to contain: a tsconfig.json with // comments raises ParserError, and a mkdocs.yml carrying a !!python/name: tag raises ConstructorError. Confirmed against cfn_tools directly. Consequence differs by caller, and only one of the two was actually broken. cfn_nag_scanner.py:408 already wraps its call in `except Exception` and continues, so it skipped the file correctly by accident. cdk_nag_wrapper.py:797 sits in a try/finally with no handler, so the exception propagated to cdk_nag_scanner.py:1106 and landed in the `except Exception` there, which does `targets_failed += 1` and appends to `self.errors`. A non-CloudFormation file was therefore counted as a cdk-nag target that failed rather than one that was skipped, and since scanner status goes ERROR once `targets_failed >= targets_attempted`, a scan set whose only candidates are unparseable reported ERROR -- which `--fail-on-incomplete-scanners` then turns into a non-zero exit. The read moved inside the try along with the parse. A file that is not valid UTF-8 fails at `f.read()` and would have escaped by the same route, so leaving it outside would have fixed one instance and left the class. No new signal was invented: None already meant "no usable template here", which is what both callers test for and what the three existing tests assert. Four regression tests, controlled in both directions: against this commit's source the module is 13 passed; with the source reverted to its previous form and the tests kept, 4 failed / 9 passed, each new test failing with the real exception (ParserError, ConstructorError, UnicodeDecodeError, FileNotFoundError) rather than on collection. Wider run: 332 passed, 14 skipped, 1 xfailed, 0 failed across the 347 tests matching cfn_template/cfn_nag/cdk_nag. ruff format clean and no new ruff findings -- the 9 this file reports are identical at HEAD. Leaves alone the separate arm where cdk-nag reports "No rules were evaluated, so this template was NOT scanned" on templates that do parse. That is issue #579, scoped to cdk_nag_wrapper.py. * Revert "fix: skip unparseable files instead of raising in get_model_from_template" This reverts 279f122. The behavior it changed is deliberate, and an existing test pins it: tests/integration/scanners/test_cdk_nag_real_pack.py, class TestTargetThatCouldNotBeParsed. Its UNPARSEABLE_TARGETS fixture is byte-identical to the two cases the revert commit added tests for -- a mkdocs.yml carrying a !!python/name: tag and a tsconfig.json with // comments. That test asserts `targets_attempted == 3` and `targets_failed == 2`. With get_model_from_template returning None for those files instead of raising, they stop being targets at all: measured locally, the scanner reports `targets_attempted=1, targets_failed=0` on a scan set holding two files it could not parse. A parse failure reaches `targets_failed` and the `exitCodeDescription` error channel precisely by raising, so swallowing it makes cdk-nag report nothing wrong about files it never scanned. That is worse than the symptom being fixed. The symptom was already investigated, and the test's own docstring records the finding: ASH's CI does log two parse failures next to a non-zero exit citing "1 actionable findings", but the summary table attributes that finding to detect-secrets at CRITICAL with cdk-nag on Action 0 / PASSED. Two unrelated facts printed near each other. The docstring says so in as many words -- "there is nothing to fix here" -- and exists to pin a correct property that nothing asserted. It also anticipates the partial-coverage argument the reverted commit made. Status only goes ERROR once `targets_failed >= targets_attempted`, so a scan that lost some targets keeps a clean rolled-up status. The docstring names that as real and separate, deliberately not fixed there. Whatever the remedy is, it is in how status is rolled up, not in making the failures invisible. Why local verification missed it: tests/conftest.py skips anything whose keywords include "integration", so the default pytest run reports this file as skipped rather than run. It needs --run-integration with ASH_REQUIRE_CDK_EXTRA=1. The reverted commit's 347-test run excluded it and read as green. * fix(ci): retry the nerdctl build past the containerd snapshot GC race Cherry-picked from 6952f63 on fix/nerdctl-snapshot-unpack. The comment block is that commit's, unchanged; the original message follows below the resolution note. CONFLICT RESOLUTION, because this file also carries the --no-run fix in this branch The source commit's retry invokes `ash build-image --oci-runner nerdctl "${force_args[@]}"`. On this branch that is not safe: the preceding commit adds --no-run to all three build legs because `ash build-image` defaults to build-and-scan and scans `Path.cwd()`, the checkout. Without --no-run every attempt here would scan the repository, and its exit 2 on findings is not the race this loop matches -- it would fail the `grep` and abort, reporting a build break that never happened. So the retried invocation carries --no-run, in the same flag order the podman and finch legs use on attempt 1. Nothing else about the retry changed. --- original message --- `nerdctl build` loses a race with containerd's garbage collector after the image has already been built: every stage completes, the manifest and tarball export, and then the load into containerd fails with `parent snapshot <digest> does not exist`. The message comes from containerd's client `Unpack`, whose per-layer Stat-then-Prepare window holds no lease on the parent, so a concurrent GC pass can collect it between the two calls. buildkit fixed the same race in its own exporter and that fix is present in the bundled buildkit, which is why the build half succeeds. Nothing has landed for the containerd-client side that nerdctl's tarball round trip routes through, so there is no version to bump. The retry only ever fires for this one error; any other non-zero status exits immediately with its own code, so a real break still fails fast on attempt 1. Retries drop --force -- attempt 1 still proves a from-scratch build works, and reusing the layers just built means the retry spends about a minute re-running precisely the operation that raced. The half-imported image record is removed first, so the retry rebuilds the snapshot chain instead of taking the Stat shortcut over it. Rejected: pointing buildkitd at the containerd worker, which would route the unpack through buildkit's fixed exporter but make this gate test a configuration no nerdctl-full user has. Also rejected: continue-on-error, which discards the signal rather than relocating it. Known limitation, stated so it can be checked: no re-run of a job that hit this error exists in the history, so "a retry succeeds" rests on the mechanism and on cross-run evidence, not on an observed flip. The ::warning:: on the retry-success path is what closes that gap -- it makes each retry countable in the Actions UI. * fix(ci): match the snapshot race on one line, and correct its rate Two defects in the retry added by the previous commit, both found by review. The error match was two independent greps over the whole build output, one for "parent snapshot" and one for "does not exist" -- the same shape ddev/ddev#8142 used. Two unrelated lines satisfy it. Measured against a fixture printing "reusing parent snapshot layer cache" and, two lines later, "requirements.txt: does not exist", the two-grep form classified a genuine build break as the race, spent both retries on it, and reported "this is containerd/nerdctl#3420, not an ASH defect" about a real ASH defect. The exit code survived so the job still failed, but the log told the next reader the wrong cause. Now one line must carry both. containerd emits the whole thing as a single message -- client/image.go:349 wraps the snapshotter error as `apply layer error for %q: %w` -- and `parent snapshot <digest> does not exist` appears exactly once, unsplit, in each of the three observed failures. Controls both ways: the regex still matches all three real race logs, and does not match any of the five branch-defect logs or the split-phrase fixture. `apply layer error` is deliberately not also required, being nerdctl's wrapper rather than the race. The stated rate was wrong. "One run in eighteen" is 8 failures over 144 terminal outcomes -- every failure of both modes -- sitting in the same comment that correctly separates them into 3 race and 5 branch defect. The race rate is 3 in 139, one run in forty-six, and the comment now shows the arithmetic: 168 runs swept, 158 producing a nerdctl job (7 produced none, 3 returned HTTP 502 on every retry and are counted unknown rather than as passes, and 158 + 7 + 3 = 168), splitting 136 success, 8 failure, 14 cancelled; 144 terminal, less the 5 branch-defect failures that also failed podman and finch in exactly those same five runs, leaves 3 in 139. Verified: seven cases against the extracted run block under the composite step's own shell flags -- race then succeed, race throughout, non-race failure, clean pass, click UsageError exit 2, ANSI-prefixed race line, and the split-phrase break that the old form got wrong. shellcheck -S style clean; test_oci_runner_ci_coverage.py 5 passed. * fix(ci): make the --no-run guard see the build inside the retry loop The guard added earlier in this branch tested `stripped.startswith("run:")`. That covered podman and finch, whose builds are one-liners, and stopped covering nerdctl the moment the cherry-picked retry moved its invocation inside a `run: |` block -- the line no longer begins with `run:`. The guard kept passing on two legs out of three, which is the worst way for it to be wrong: it read as a guard while leaving uncovered the one leg most likely to be edited next. This is a defect in the guard, not in the retry, which is why it is separate from the cherry-picks rather than folded into them. Two changes. The shape test is now "the command is the first thing on the line, after an optional `run:`", which matches both forms. Four kinds of line in this file name `ash build-image` without invoking it -- the prose at the top, the two comment blocks, this check's own source, and the `echo "::error::ash build-image ..."` in the retry loop -- and all four stay excluded. And the count is asserted. Without it, an edit that hides an invocation from the shape test leaves the check passing on whatever it still sees, which is precisely how the `run:`-only version failed. It now names the runtime it cannot find. Controlled four ways, by extracting the check verbatim from this file and running it against mutated copies: as committed PASS, all 3 legs found --no-run dropped from the nerdctl retry FAIL, names the multi-line invocation --no-run dropped from the podman one-liner FAIL, names the one-liner nerdctl invocation hidden behind `eval` FAIL, "found no build invocation for ['nerdctl']" The second of those is the case that matters: run against that same mutated file, the previous `run:`-only version of this check printed PASS and exited 0.
failed to prepare extraction snapshot "...": parent snapshot ... does not exist: not found#8136Docker 29+ with containerd image store (now default) has a race condition in BuildKit (moby/buildkit#6521) where parallel service builds sharing base layers fail non-deterministically with "parent snapshot ... does not exist: not found" during image export/unpack.
Changes
Extracted
composeBuild()method from inline build logic inStart()"web","--no-cache")composeBuildMaxRetriesconstant)"parent snapshot"and"does not exist"util.Debug(), warns user on retries withutil.Warning()Updated
Start()method to usecomposeBuild()in both build locations:app.composeBuild()app.composeBuild("web", "--no-cache")(preserves original behavior of rebuilding dirty web images with --no-cache)Added code comments noting this is experimental workaround for upstream issue
Example Error Detection
Net result: transparent retry on snapshot race, unchanged behavior otherwise.
> [!WARNING]
>
>
This pull request was created from Copilot chat.
>
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.