Skip to content

engine: add engine-managed volumes - #13719

Merged
sipsma merged 7 commits into
dagger:mainfrom
sipsma:engine-managed-volumes
Aug 4, 2026
Merged

sipsma merged 7 commits into
dagger:mainfrom
sipsma:engine-managed-volumes

Conversation

@sipsma

@sipsma sipsma commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Summary

Dagger engine operators can attach storage beneath the engine state directory, but clients currently cannot expose that live operator-managed storage through the opaque Volume API. This adds engine-managed volumes: for example, engineVolume("datasets/models", subdir: "llama") mounts the operator-controlled directory at <engine-root>/volumes/v1/datasets/models/fs/llama.

The public API is Query.engineVolume(name, subdir?), with CLI/module arguments using addresses such as:

engine-volume://datasets/models?subdir=llama

Modules cannot construct engine volumes, matching the existing SSHFS product boundary, but they can accept and mount an opaque Volume supplied by their caller.

Architecture and behavior

  • The engine stores only the canonical volume name, optional subdirectory, and layout version in the Volume; the host path is resolved lazily against the configured engine root at exec time.
  • Named roots are created as 0755 when absent. Existing operator-owned objects are preserved, and an explicitly selected subdirectory must already exist.
  • Mounts are recursive binds, so nested operator mount points remain visible. The executor owns the container-lifetime bind and recursively tears it down on success, cancellation, disconnect, partial failure, and shutdown. Backing storage remains operator-owned and persistent.
  • Read-only mounts use rbind,rro when the engine supports recursive mount_setattr. The engine probes that capability once at startup in an isolated mount namespace. Older or syscall-restricted environments fall back to rbind,ro, where the top-level bind is read-only but nested mounts retain their existing flags.
  • Cache identity is based on constructor arguments, not mutable filesystem contents. Dagger does not hash, watch, snapshot, lock, prune, or account for this operator-managed storage.
  • Callers select from the operator-curated engine namespace; they cannot submit arbitrary host paths. This is intentionally an engine-operator trust boundary, not generic multi-tenant host-filesystem access.

The detailed design is checked in at hack/designs/engine-volumes.html.

Validation

Non-goals

  • Arbitrary caller-selected host paths.
  • Dagger-managed pruning, quotas, locking, snapshots, content hashing, or mutation-driven cache invalidation.
  • Configurable mount propagation or automatic creation of the optional subdirectory in this initial version.

@sipsma
sipsma requested review from a team as code owners July 22, 2026 23:36
@grouville
grouville self-requested a review August 3, 2026 17:53
@grouville

grouville commented Aug 4, 2026 •

Copy link
Copy Markdown
Member

Hey, amazing feature ! 🙏

I’ve been reading the design docs and I’ve got a question about one point for v1:

  • §6 says that changing a path between validation and mount is not protected in v1
    <section id="trust"><h2>6. Real trust and security boundary</h2>
    <p>The <strong>engine operator</strong> chooses what exists or is mounted beneath <code>volumes/v1</code>. That operator already controls the engine process, its state volume, privileges, and namespace. Dagger intentionally trusts this setup. A <strong>main client</strong> may select only a validated name and subdirectory within that operator-curated tree; it may not submit an arbitrary host path. A <strong>module</strong> cannot construct the capability but may use one passed by its caller.</p>
    <p>With a remote engine, “host” means the engine host/container namespace—not the CLI machine. An operator who exposes sensitive material beneath the namespace makes it selectable by main clients. This feature therefore belongs only on engines whose main clients are trusted for that capability. The module restriction improves product portability and intent; it is not an ACL and must not be described as one.</p>
    <p>Path validation prevents traversal and uses the existing continuity safe-root semantics: symlinks are resolved as if chrooted within the containment root, so absolute targets and <code>..</code> cannot escape it. An apparent outside target is clamped to an in-root path and may then fail as missing or the wrong type; it is not promised to produce a distinct “escape” error. Operators must use bind mounts—not symlinks—to redirect a volume hierarchy to storage outside <code>volumes/v1</code>. Symlinks <em>inside the mounted payload</em> retain ordinary filesystem behavior after the source has been safely selected. Because the operator is trusted, v1 does not promise protection from an operator concurrently replacing path components between validation and mount; claiming adversarial multi-tenant TOCTOU safety would require descriptor/openat2-based mounting and a broader threat model.</p>
  • But §8 says that Dagger will only mount paths inside `volumes/v1
    <section id="invariants"><h2>8. Ownership and invariants</h2>
    <table><thead><tr><th>Area</th><th>Invariant</th></tr></thead><tbody>
    <tr><td>Identity</td><td>Canonical <code>name</code> and <code>subdir</code> identify a recipe. Rejecting rather than normalizing equivalent alternate spellings is the recommendation, not an explicit Erik decision.</td></tr>
    <tr><td>Containment</td><td>Name stays beneath <code>volumes/v1</code>; subdir stays beneath that volume’s <code>fs</code>. Absolute/traversal syntax fails; symlinks resolve chroot-style within the appropriate containment root and cannot select an outside source.</td></tr>

I have a repro here of a client-side TOCTOU: a writable exec changes the subdirectory after it has been checked, and the mount can then point outside volumes/v1, though still within the engine's own filesystem namespace (not the host, and not another tenant's engine).

Am I understanding correctly that this is an intentional exception for v1, and that containment inside volumes/v1 is not guaranteed when this race happens? I just want to make sure I understand this subtlety correctly.

@sipsma
sipsma merged commit 6fe2777 into dagger:main Aug 4, 2026
87 checks passed
pull Bot pushed a commit to Mu-L/dagger-1 that referenced this pull request Aug 5, 2026
Rebasing onto main picked up Query.volume (dagger#13719), whose additions to the
schema and every client collided with this stack's own generated output.
The conflicts were resolved by regenerating rather than merging by hand,
so this is codegen output only - no hand edits.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Aug 6, 2026
Rebasing onto main picked up Query.volume (#13719), whose additions to the
schema and every client collided with this stack's own generated output.
The conflicts were resolved by regenerating rather than merging by hand,
so this is codegen output only - no hand edits.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Aug 6, 2026
Rebasing onto main picked up Query.volume (#13719), whose additions to the
schema and every client collided with this stack's own generated output.
The conflicts were resolved by regenerating rather than merging by hand,
so this is codegen output only - no hand edits.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Aug 6, 2026
Rebasing onto main picked up Query.volume (#13719), whose additions to the
schema and every client collided with this stack's own generated output.
The conflicts were resolved by regenerating rather than merging by hand,
so this is codegen output only - no hand edits.

Signed-off-by: Alex Suraci <[email protected]>
vito added a commit that referenced this pull request Aug 7, 2026
Rebasing onto main picked up Query.volume (#13719), whose additions to the
schema and every client collided with this stack's own generated output.
The conflicts were resolved by regenerating rather than merging by hand,
so this is codegen output only - no hand edits.

Signed-off-by: Alex Suraci <[email protected]>
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