Repository navigation
engine, cli: let a Dagger CLI join the session of the client that serves it - #14875
Merged
Merged
Conversation
…ves it `dagger api with-session`, `dagger run` and `dagger session` refused a Dagger CLI child: they forwarded every request to the engine as their own, so a CLI child's shutdown would have ended their client. A client now passes a child's client metadata on to the engine as its child's, under its own. The engine registers that child as a nested client of the client that serves it, as it does for a CLI in a container exec: it shares that client's session and host access, and its shutdown ends only itself. A client's children close when it closes. Signed-off-by: Erik Sipsma <[email protected]>
A child's requests declare its version, labels and what it loads, which replace its parent's. Registering the child with its parent's values made its first request conflict with them. Signed-off-by: Erik Sipsma <[email protected]>
Registering a child needs its parent's executable scope. A child's /init, /shutdown and attachables requests admitted the parent as a bootstrap-only request, which has that scope only if the parent had already sent a query. Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
grouville
self-requested a review
October 27, 2026 07:15
grouville
approved these changes
Oct 27, 2026
sipsma
added a commit
that referenced
this pull request
Oct 28, 2026
A command under `dagger run`, `dagger api with-session` or `dagger session`, or in a container exec, joins that session as a nested client (#14875), whatever session it asks for. With --detach it printed the ID of a session that did not exist, and its work ended with the session it ran in; --session was ignored. Refuse both there, with an error that says why. Signed-off-by: Erik Sipsma <[email protected]>
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.
A Dagger CLI started as a child of
dagger api with-session,dagger runordagger sessionwas refused withconnecting a Dagger CLI to the session served by `dagger run` is not supported yet(added in #14708). Those commands forwarded every request from their children to the engine as their own, so a CLI child's/initand/shutdownwould have acted on the parent's client, and the child exiting would have ended the parent's whole session.This lets such a CLI join the session as its own client, the same way a CLI inside a container exec already joins its caller's session.
X-Dagger-Child-Client-Metadataheader, under its own metadata, instead of overwriting it. Each hop appends, so a child of a child works too.dagger listen, which before this would have acted as thedagger listenclient.This matters for dagger/go#80, which runs Go module tests under
dagger api with-session: a test that runs thedaggerCLI as a subprocess fails there today.How it was verified
TestContainer/TestNestedDaggerCLIServesChildused to expect the refusal. It now expects CLI children to work, and addswith-sessioncases: a CLI child, a CLI child reading host files, two CLI children in turn followed by a query from the parent's session, and a child of a child. Each case runs both in an exec that joins the caller's session and withdaggerInDaggerNewSession, wherewith-sessionis the root client of its own session. All 16 cases pass. Against main, the 12 CLI-child cases fail with "not supported yet" and the other 4 pass.TestClientServesChildClients.