Skip to content

ci: keep dev-engine clients off the outer engine's session; state nesting and GPU gates as v1.0 - #14342

Merged
sipsma merged 6 commits into
dagger:mainfrom
sipsma:explicit-engine-routing
Sep 25, 2026
Merged

sipsma merged 6 commits into
dagger:mainfrom
sipsma:explicit-engine-routing

Conversation

@sipsma

@sipsma sipsma commented Sep 25, 2026 •

Copy link
Copy Markdown
Contributor

Why

Since native CI's outer engine moved from v1.0.0-beta.14 to a main build (3924c43) on 2026-09-25, most PRs and main fail the same checks: python-client, rust-client and elixir-client up-to-date, plus about twelve test-split shards.

The cause is default nesting (#14082). On the v1.0 API, every container exec gets DAGGER_SESSION_PORT/DAGGER_SESSION_TOKEN for the engine running it. engine-dev declares engineVersion = "v1.0.0-0". Views drop the prerelease suffix, so it gets the v1.0.0 view and its execs are nested. Dagger clients (the CLI and the Go SDK) prefer that session over _EXPERIMENTAL_DAGGER_RUNNER_HOST. So the test binaries and codegen introspect, which InstallClient points at the dev engine, joined the outer CI engine instead:

  • Tests failed with cannot configure workdir for existing session, Cannot query field "withGPU", missing test services, and similar errors.
  • Generated Python, Rust and Elixir clients came from the outer engine's older schema. They lacked withGPU from core: add Container.withGPU, deprecate experimental GPU fields #14320, so the up-to-date checks reported changes. Go, TypeScript and PHP generate from v0.21.9 modules, which are not nested, so they passed.

What changes

ci: keep dev-engine clients off the outer session. The execs that must reach a dev engine now unset the session at the process boundary (env -u DAGGER_SESSION_PORT -u DAGGER_SESSION_TOKEN):

  • engine-dev: schema introspection and the test runner;
  • engine-lab: the dagger and query commands;
  • dagger-dev: the smoke check.

WithoutEnvVariable cannot do this, because the engine sets the variables when the process starts. This works whether or not the outer engine nests by default, so main and PRs go green on the current CI engine without re-pinning.

core: gate nesting and withGPU on the v1.0 view. engine.BaseVersion strips prereleases when deriving views, so every v1.0.0 prerelease caller gets the v1.0.0 view. The previous v1.0.0-beta.15 gates read as if beta.14 and earlier callers keep the old behavior, but that boundary cannot be reached. Every v1.0.0 prerelease caller already gets nesting by default and withGPU.

  • The gates are now stated as v1.0.0-0. Behavior is unchanged.
  • The new engine.APIViewVersion is the single mapping from declared version to view, used at the existing call sites.
  • The gate tests build views through that mapping instead of raw prerelease strings that the engine never produces.
  • The changelog entries and internal-docs/version-gating.md are corrected. The doc now explains that views cannot separate prereleases of one version, and points to exact declared-version checks (such as callerPastChangesetCwdCutover) when behavior must differ.

Reverted in this PR: client-side precedence. An earlier commit here made an explicit engine selection outrank an injected session in the CLI and Go SDK. CI caught a regression: TestListen/TestDaggerListen/serves_explicit_workspace_entrypoint. dagger listen and dagger api with-session hand DAGGER_SESSION_PORT/TOKEN to clients on purpose, and a client cannot tell those from an injected session. That change is reverted, and client precedence matches main.

Validation

Run locally against the same outer engine native CI uses (CLI and engine at 3924c43):

  • dagger check python-client:client-library:up-to-date
  • dagger api call engine-dev test --pkg ./core/integration --run='TestAddress/TestLocalFile|TestFile/TestExport|TestListen'
    • This branch: all 12 pass.
    • On unmodified main, TestAddress/TestLocalFile fails with cannot configure workdir for existing session.
  • dagger check smoke (dagger-dev) passes, and dagger api call engine-lab --help loads the module.
  • go test -run 'TestNesting|TestGPU' ./core/schema/ passes.
  • CI on the earlier head of this PR passed every previously failing shard and generated-client check, except TestListen, which the revert addresses. Eight failures there were Cloud connection resets or removed outer sessions after the checks' own work had passed, and all of them passed on rerun.

Not in this PR

  • Follow-up for the injection point: the engine could stop injecting the nested session into an exec whose own environment already selects another engine (runner host, DAGGER_ENGINE, DAGGER_CLOUD_ENGINE). That would remove this footgun for users without changing clients. It needs a decision from the owners of default nesting.
  • The older view gates at v1.0.0-beta.10, -beta.11 and -beta.12 (Git bundles, File bytes, lookup locking, latest-release and version queries) have the same unreachable-boundary problem. Their unit tests set raw prerelease views and assert differences between them that production views cannot have, so they need their owners' review.
  • Other PRs need a rebase onto main after this merges.

…ssion

Container execs now reach their engine by default: the engine injects
DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN into every exec on the v1.0
API. The CLI and the Go SDK used that session whenever it was present,
even when the process had selected a different engine explicitly. A
client pointed at a dev engine with _EXPERIMENTAL_DAGGER_RUNNER_HOST
silently joined the outer session instead.

This broke Dagger's own CI once native CI's outer engine included
default nesting: engine-dev's integration tests and schema introspection
talked to the outer engine rather than the dev engine under test, so
tests failed with "cannot configure workdir for existing session" and
generated clients were built from the outer engine's older schema.

Treat an explicit engine selection as outranking the injected session:
- the CLI connects to its runner host when --engine, --cloud,
  DAGGER_ENGINE, DAGGER_CLOUD_ENGINE or _EXPERIMENTAL_DAGGER_RUNNER_HOST
  selects an engine;
- the Go SDK skips the session env when a runner host is configured or
  one of those variables is set, and drops the session variables from
  the CLI it starts, so an older CLI routes the same way.

Without an explicit selection, nested clients keep using the injected
session.

Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
API views are base-version granular: the engine strips prerelease
suffixes when deriving a view, so every v1.0.0 prerelease, from
v1.0.0-0 through v1.0.0-beta.15, gets the v1.0.0 view. The nesting
default and Container.withGPU were gated at v1.0.0-beta.15, which reads
as if beta.14 and earlier callers keep the old behavior, but no view
can fall below that boundary while being a v1.0.0 prerelease. Both
already apply to every v1.0.0 prerelease caller.

State the gates as v1.0.0-0 so the code says what callers get. Add
engine.APIViewVersion as the single declared-version-to-view mapping,
and build the gate tests' views through it instead of from raw
prerelease strings that the engine never produces. Correct the
changelog entries and the version-gating internal doc accordingly.

Signed-off-by: Erik Sipsma <[email protected]>
Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma requested a review from a team as a code owner September 25, 2026 04:02
…ected session"

This reverts commit 5931ca1.

DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN are not only injected by
the engine for nesting. `dagger listen` and `dagger api with-session`
hand them to clients on purpose, and with-session passes the user's
whole environment along. With an engine selector such as
_EXPERIMENTAL_DAGGER_RUNNER_HOST or DAGGER_ENGINE also set, the reverted
change made the client skip that deliberate session and start its own:
TestListen/TestDaggerListen/serves_explicit_workspace_entrypoint failed
with `unknown command "hello" for "dagger call"`. A client cannot tell
an injected session from a deliberate one, so keep the existing
precedence and opt out where a caller must reach another engine.

Signed-off-by: Erik Sipsma <[email protected]>
On the v1.0 API, container execs get DAGGER_SESSION_PORT/TOKEN for the
engine running them, and Dagger clients prefer that session over
_EXPERIMENTAL_DAGGER_RUNNER_HOST. engine-dev (v1.0.0-0), engine-lab
(v1.0.0-0) and dagger-dev (v1.0.0-beta.12) all get the v1.0.0 view, so
once native CI's outer engine nested by default, their clients joined
the outer CI engine instead of the dev engine under test:
integration tests failed with "cannot configure workdir for existing
session" and similar errors, and the Python, Rust and Elixir clients
were generated from the outer engine's older schema.

Unset the session at the process boundary for the execs that must
reach a dev engine: engine-dev's schema introspection and test runner,
engine-lab's dagger and query commands, and dagger-dev's smoke check.
WithoutEnvVariable cannot do this because the engine sets the variables
when the process starts. This works with outer engines that nest by
default and with those that do not.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma sipsma changed the title Prefer an explicitly selected engine over an injected nested session ci: keep dev-engine clients off the outer engine's session; state nesting and GPU gates as v1.0 Sep 25, 2026
@sipsma
sipsma requested a review from grouville September 25, 2026 05:08
@sipsma
sipsma merged commit 93624bd into dagger:main Sep 25, 2026
86 checks passed
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