Skip to content

fix(engine): lease parent layer content for tarball export - #13307

Merged
sipsma merged 1 commit into
dagger:mainfrom
sipsma:missing-content
Jun 2, 2026
Merged

sipsma merged 1 commit into
dagger:mainfrom
sipsma:missing-content

Conversation

@sipsma

@sipsma sipsma commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

Problem

Container image tarball export can fail after cache pruning when the export needs layer content that is no longer retained by an owner lease. The observed failure was intermittent during engine builds, especially through Container.asTarball(forcedCompression: Zstd), with errors like a missing local content blob or a content digest not found while ensuring the requested compression type.

Root Cause

Dagger owner leases only retained the snapshot directly attached to a persisted result, plus content digests already recorded for that direct snapshot. Image export walks the full snapshot parent chain, while imported image blobs and generated compression variants are recorded against the individual layer snapshots in that chain. That left parent layer content eligible for prune even when a descendant container result remained retained and usable.

The filesystem snapshot could still be read after prune, but export could fail because the layer blob or zstd compression variant needed to construct the tarball had been reclaimed.

Fix

When attaching an owner lease, walk the snapshot parent chain and attach each snapshot plus its known content digests to the same containerd lease. Also register the owner lease against each snapshot in the chain, so content recorded later for any ancestor snapshot, including zstd compression variants, is backfilled to the active owner lease.

This keeps tarball-export layer content retained for the same lifetime as the retained container result without changing stale-lease cleanup semantics.

Validation

Added an integration repro that:

  • creates a container and exports it once as a zstd tarball
  • closes the producing session
  • pins the container in a new session
  • creates additional cache pressure
  • prunes aggressively
  • verifies the pinned filesystem is still readable
  • exports the pinned container as a zstd tarball again

Validated with:

  • go test ./engine/snapshots
  • dagger --progress=plain call engine-dev test --pkg ./core/integration --run='^TestLocalCache/TestLocalCachePruneDoesNotDropZstdTarballLayerContent$'

Dagger owner leases only retained the snapshot directly attached to a persisted result, along with content digests already recorded for that one snapshot. Image export walks the full snapshot parent chain, and imported base image layer blobs plus generated compression variants are recorded against the individual layer snapshots in that chain. After the producing session ended, prune could therefore reclaim parent layer content that was still needed by a retained container result.

This showed up as intermittent Container.asTarball(forcedCompression: Zstd) failures during engine builds: the retained container filesystem could still be read, but export could no longer find a local layer blob or compression variant.

When attaching an owner lease, walk the snapshot parent chain and attach each snapshot and its known content digests to the same containerd lease. Also register the owner lease against each chain snapshot so content recorded later, such as zstd variants, is backfilled to the lease.

Add an integration repro that pins a container across sessions, creates zstd tarball content, prunes aggressively, verifies the filesystem remains readable, then exports the pinned container as a zstd tarball again.

Validated with:

- go test ./engine/snapshots

- dagger --progress=plain call engine-dev test --pkg ./core/integration --run='^TestLocalCache/TestLocalCachePruneDoesNotDropZstdTarballLayerContent$'

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma sipsma added this to the v0.21.4 milestone Jun 2, 2026
@grouville
grouville self-requested a review June 2, 2026 18:16
@sipsma
sipsma merged commit 41a7910 into dagger:main Jun 2, 2026
77 checks passed
tiborvass added a commit that referenced this pull request Jun 5, 2026
…ash in fd0021b

This merge commit restores the history link between 1.0-beta branch and main.
It was lost with merge commit fd0021b which
squashed the branch e45e7e4

Git tree on #13327 before squash-merging into 1.0-beta:

```
* e45e7e4 Run dagger generate
*   a01677a Merge main into 1.0-beta
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| * 20b2554 Simplify function call return handling (#13319)
| * 316ca15 Fix snapshot owner lease attach/remove race (#13321)
| * 6cfdcb4 fix(layercopy): follow source symlinks when copying directory contents (#13326)
| * 16e85ca Container exists expand option (#13310)
| * 54f9811 chore: post-release during v0.21.4 (#13316)
| * de85595 ci: bump default engine version to v0.21.3 (#13315)
| * 81bb907 chore: prep for v0.21.4 (#13314)
| * 0fd148e Show root usage when dagger has no args
| * 219b696 Volatile vars (#13223)
| * fae340c fix(layercopy): materialize resolved parent dirs when writing through… (#13308)
| * b720144 bump dang (#13306)
| * 41a7910 fix(engine): lease parent layer content for tarball export (#13307)
| * b2d43ba fix(core): attach never-cached module function results (#13298)
| * 6a7b3a7 fix incorrect artifact caching issue when releasing  (#13285)
| * 2452472 fix(core/dotenv): accept `export`-prefixed lines in .env files (#13293)
| * 24b06e7 fix: allow empty setSecret name (#13304)
| * f7ea195 fix: handle 1Password secrets with spaces (#13297)
* | 74e1a66 another pass on docs (#13325)
...
|/
* 8cc840f fix(sdk/typescript): resolve referenced values in decorator arguments (#13292)
```

Ran `git merge -s ours 1588421` on 1.0-beta to get this desired git tree:

```
*   ??gitsha?? [1.0-beta] restore merge history with main@15884210ff lost due to squash in fd0021b
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| ...
* | 94ebacb (origin/1.0-beta) update sdk docs, type-system docs, and interfaces (#13338)
* | 64eba3f (tag: v1.0.0-beta.3) [1.0-beta] feat: support synthetic workspaces (#13217)
* | fd0021b Merge main into 1.0-beta (#13327)
* | c6dd435 fix(cli): refine cloud check replay
```
tiborvass added a commit that referenced this pull request Jun 6, 2026
…ash in fd0021b

This merge commit restores the history link between 1.0-beta branch and main.
It was lost with merge commit fd0021b which
squashed the branch e45e7e4

Git tree on #13327 before squash-merging into 1.0-beta:

```
* e45e7e4 Run dagger generate
*   a01677a Merge main into 1.0-beta
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| * 20b2554 Simplify function call return handling (#13319)
| * 316ca15 Fix snapshot owner lease attach/remove race (#13321)
| * 6cfdcb4 fix(layercopy): follow source symlinks when copying directory contents (#13326)
| * 16e85ca Container exists expand option (#13310)
| * 54f9811 chore: post-release during v0.21.4 (#13316)
| * de85595 ci: bump default engine version to v0.21.3 (#13315)
| * 81bb907 chore: prep for v0.21.4 (#13314)
| * 0fd148e Show root usage when dagger has no args
| * 219b696 Volatile vars (#13223)
| * fae340c fix(layercopy): materialize resolved parent dirs when writing through… (#13308)
| * b720144 bump dang (#13306)
| * 41a7910 fix(engine): lease parent layer content for tarball export (#13307)
| * b2d43ba fix(core): attach never-cached module function results (#13298)
| * 6a7b3a7 fix incorrect artifact caching issue when releasing  (#13285)
| * 2452472 fix(core/dotenv): accept `export`-prefixed lines in .env files (#13293)
| * 24b06e7 fix: allow empty setSecret name (#13304)
| * f7ea195 fix: handle 1Password secrets with spaces (#13297)
* | 74e1a66 another pass on docs (#13325)
...
|/
* 8cc840f fix(sdk/typescript): resolve referenced values in decorator arguments (#13292)
```

Ran `git merge -s ours 1588421` on 1.0-beta to get this desired git tree:

```
*   ??gitsha?? [1.0-beta] restore merge history with main@15884210ff lost due to squash in fd0021b
|\
| * 1588421 chore: update daggerverse from 0.21.0 to 0.21.4 (#13328)
| ...
* | 94ebacb update sdk docs, type-system docs, and interfaces (#13338)
* | 64eba3f [1.0-beta] feat: support synthetic workspaces (#13217)
* | fd0021b Merge main into 1.0-beta (#13327)
* | c6dd435 fix(cli): refine cloud check replay
* | 74e1a66 another pass on docs (#13325)
```
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.4

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v0.21.4 - 2026-06-03

### Fixed
- Fix a regression in the 1Password secret provider where secrets with spaces could not be resolved. dagger/dagger#13297
- Container image tarball export can fail after cache pruning when the export needs layer content that is no longer retained by an owner lease. The observed failure was intermittent during engine builds, especially through Container.asTarball(forcedCompression: Zstd), with errors like a missing local content blob or a content digest not found while ensuring the requested compression type. dagger/dagger#13307
- When WithFile/WithDirectory writes to a path that traverses a symlinked directory (e.g. ubuntu's /bin -> usr/bin), ensureDir resolved the symlink to the real view path but recursed on the parent of the original destPath instead of the parent of the resolved path. On a fresh overlay layer this skipped materializing intermediate dirs (e.g. usr) in the upperdir, so materializeExistingDir failed with 'mkdir .../usr/bin: no such file or directory'. dagger/dagger#13308

### What to do next?
- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)

</pre>
  <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.4">https://github.com/dagger/dagger/releases/tag/v0.21.4</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!10344
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants