Skip to content

Move the repository's Go modules to the go-sdk Dang entrypoint - #15070

Closed
sipsma wants to merge 36 commits into
mainfrom
sipsma/go-modules-dang-entrypoint
Closed

sipsma wants to merge 36 commits into
mainfrom
sipsma/go-modules-dang-entrypoint

Conversation

@sipsma

@sipsma sipsma commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Draft: based on main. It stays a draft until per-package Go builds land in this PR and remove the fresh-engine cost described below.

Supersedes #14840 and #14905 by @eunomie, whose commits are kept here as theirs, rebased and regenerated with go-sdk v1.4.0.

What it does

15 of the repository's own Go modules get a generated Dang entrypoint, unified clients and no global client:

  • .dagger/modules/go, cli-dev, docs-dev, docs-dev/docusaurus, engine-dev, engine-dev/notify;
  • php-client-dev, python-client-dev, python-client-dev/dockerd, rust-client-dev, tla-check;
  • release, release/gh, release/registry-config;
  • modules/git-releaser.

The engine reads their types from the generated Dang file, so listing the workspace's checks no longer compiles them. release/apko stays on the Go runtime.

What it changes for users

dagger -W github.com/dagger/dagger@<commit> check -l, on one 16-CPU machine, a priming run and 2 interleaved pairs, against #15063's head:

Step Before After Difference (2 pairs)
Fresh engine 29.3 s 16.5 s −12.8 s (the pairs: −14.3 and −11.3 s)
After main moved (the same 89 commits in both) 7.7 s 5.6 s −2.1 s
Unchanged 1.1 s 1.0 s none

Both arms listed the same checks, plus go-sdk generate/stale here, which this turns back on.

These were measured against #15063's head before its sparse git workspace load. Against today's main, the fresh step gains about 8 to 9 s, and the step after main moves is slower; see the known cost below.

The cost, and why this is a draft

On a fresh engine, a check that calls these modules takes longer the first time. rust-client/apiclient/stale, on a git workspace, both arms on main's engine, one fresh engine per run, 6 interleaved pairs:

main This PR Difference
Mean of 6 runs 207.9 s 228.7 s +20.8 s
The 6 pairs +19.8, +26.2, +16.5, +16.4, +27.5, +18.2 s

Profiles of the check (critical path and CPU per exec) put the extra time in three places:

  • The entrypoint binaries build from an empty Go build cache. The legacy runtime's builds start from a build cache that ships in the engine image (the standard library and the Go SDK's dependencies); the entrypoints' go-sdk-v2-build volume starts empty. rust-client-dev's first build costs 54 CPU-s cold, against 1.8 CPU-s with that volume pre-warmed. The three builds on the path (rust-client-dev, engine-dev, go) run one after another, since each module is first called by the one before.
  • alpine and wolfi build their legacy runtimes later, when go first calls them, instead of while the workspace loads.
  • A second build of ./cmd/codegen recompiles from scratch (8.5 s, 68 CPU-s), where on main it reuses the first build's work (0.6 s). The engine resolves codegen's dependency on go, reached through engine-dev, without the repository's identity, so that go gets Go cache volumes of its own, empty on a fresh engine. That engine bug predates this PR.

This stays a draft until that cost is gone.

Known cost: listing after main moves

On a git workspace, listing the checks after a new commit is slower with this PR. dagger -W github.com/dagger/dagger@main check -l after main moves takes about 6.7 s, against main's 3.5 s. The fresh listing still gains about 8 to 9 s.

The generated entrypoints read files from the repository's root Go module (go.mod, util/parallel, …) to build their sources. Those fall outside what the engine fetches when it loads a git workspace sparsely, so each new commit checks out the whole tree. This is being fixed separately in the engine.

Known issue: e2e/helm TestInstallK3S from a local checkout

From a local checkout, TestInstallK3S fails ("wait for k3s readiness: exit code: 2"). CI is green because it loads a git workspace.

  • Cause: the test's Go client is its own session. When the now-entrypoint cli-dev serves its same-repo go client, the engine reads the tree from a path that another session's load of the same module recorded.
  • This is an existing engine bug in how module results carrying a local path are shared across sessions. This PR exposes it through same-repo clients.
  • It's being fixed separately, and this PR stays a draft until it is. Related: a module call's cached result doesn't cover the same-repo modules it serves, which this PR also widens.

Known flake: go-sdk/generate/stale

A generated client's enum cases come out in a different order on each generation, so go-sdk/generate/stale can flag python-client-dev's generated pytest client when the order differs from the committed one. CI generates with the released engine, which doesn't have the fix; the fix is in #15080. Until a release carries it, the check is rerun until it passes, and no order is committed.

Behaviour changes

  • With no engineVersion, a module gets the v1 view. Execs nest, so execs that start a Dagger client unset DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN.
  • A module called by another gets no workspace. Callers pass source, workspaceDir or sourceRepo, and filter directories with the callee's ignore list.
  • Every dependency's check is a Check object (fix(go): type checks as Check in unified bindings go-sdk#83). The release module's dry runs read each SDK's result from it.
  • Each entrypoint has a dang.toml naming v1.0.0-beta.24, which released engines ignore.
  • go-sdk generate/stale runs again. It took about 12 minutes on a 16-CPU engine.

Assumes dagger/go-sdk#76

Until a go-sdk release has #76, a failing function of these modules reaches its caller as "exit code: 2", with its message only in stderr. Regenerating with that release fixes this. It changes only the generated dispatch code, not the types that listing reads.

How it was made and checked

  • Commits: first a commit pinning go-sdk v1.4.0 (in place of their go-sdk main pins), then @eunomie's 29 module commits, a fix to the release module for Check, the regeneration, the Go version commit, a regeneration after rebasing onto main, a test, and python-client-dev's move.
  • python-client-dev: the workspace's go-sdk scope for it set dangEntrypoint and unifiedClients to false (chore: update module dependencies #15056); this sets both to true, like the other modules. Its format, lint and lint-docs-snippets checks now return only an error after the same work, because the engine refuses a check that returns a value for a module without engineVersion. Its go.mod moves to Go 1.26.6 like the others; a later commit moves every module to go 1.27.
  • Test: LockfileSuite.TestEntrypointModuleUsesImagePin checks that a Dang entrypoint module's image pulls follow the workspace lock's pin, both in its own code and in a process it starts with nesting, which is how the Go entrypoint runs a module's code. It runs in the base integration shards.
  • Generation: dagger generate go-sdk/generate with v1.0.0-beta.24. A second run changes nothing.
  • Checks that pass: dagger check -l, dagger generate -l --require-load and dagger check go-sdk/generate/stale.

sipsma and others added 27 commits November 5, 2026 19:06
go-sdk v1.4.0 ships the Dang entrypoint generator and targets
v1.0.0-beta.24.

Signed-off-by: Erik Sipsma <[email protected]>
The entrypoint takes the module description from the main type's doc
comment, not from the package doc comment.

Signed-off-by: Yves Brissaud <[email protected]>
go-sdk refuses [[dependencies]] and [codegen] in a manifest it moves to
an entrypoint; wolfi stays a client of the scope in dagger.toml.

Signed-off-by: Yves Brissaud <[email protected]>
go-sdk needs go.mod in the module directory and refuses
source = "dagger", so the code moves up from dagger/. The entrypoint
has no module description, so the main type's doc comment carries it.

Signed-off-by: Yves Brissaud <[email protected]>
The entrypoint takes the module description from the main type's doc
comment, not from the package doc comment.

Signed-off-by: Yves Brissaud <[email protected]>
Unified clients name the cli-dev client after its module, so the
dagger-cli alias of the old manifest becomes CliDev. Core types now
come from dagger.io/dagger/core, so staticcheck flags GitRef.Commit.

Signed-off-by: Yves Brissaud <[email protected]>
go-sdk refuses [[dependencies]] and [codegen] in a manifest it moves to
an entrypoint; alpine stays a client of the scope in dagger.toml.

Signed-off-by: Yves Brissaud <[email protected]>
An entrypoint manifest cannot carry disableDefaultFunctionCaching;
+cache="session" on each function keeps the per-session caching.

Signed-off-by: Yves Brissaud <[email protected]>
Unified clients name the engine-dev client after its module, so the
dagger-engine alias of the old manifest becomes EngineDev. Execs nest
on the v1 API, so phpunit and the codegen dagger call drop the outer
session to reach the dev engine, as with the v0.21.9 engineVersion.

Signed-off-by: Yves Brissaud <[email protected]>
Unified clients name the engine-dev client after its module, so the
dagger-engine alias of the old manifest becomes EngineDev. Execs nest
on the v1 API, so cargo test drops the outer session to reach the dev
engine, as with the v0.21.9 engineVersion.

Signed-off-by: Yves Brissaud <[email protected]>
The v1 client exposes the ReleaseDryRun checks of cli-dev and
rust-client-dev as Check objects, so the dry run reads each check's
failure from Check.error. Called from an entrypoint, contextual
defaults resolve against the callee's own module, so release passes
the workspace root as php's and python's workspaceDir and its head as
go's and php's sourceRepo. A passed directory skips the callee's
+ignore, so release filters each one with a copy of the callee's
pattern list. Execs nest on the v1 API, so the publish check's CLI
drops the outer session to reach the dev engine.

Signed-off-by: Yves Brissaud <[email protected]>
Core types now come from dagger.io/dagger/core, so staticcheck flags
GitRef.Commit. Called from engine-dev or release, cli-dev's default
source would resolve against its entrypoint sources, which lack
cmd/dagger, so those callers pass their source. A passed directory
skips the callee's +ignore, so they filter it with a copy of cli-dev's
pattern list.

Signed-off-by: Yves Brissaud <[email protected]>
go-sdk refuses [[dependencies]] and [codegen] in a manifest it moves to
an entrypoint; the four dependencies stay clients of the scope. The v1
API of the unified client deprecates GitRef.ref in favour of name.
release passes docs-dev's source, whose default would resolve against
the entrypoint sources, filtered with a copy of docs-dev's +ignore
list, which a passed directory skips.

Signed-off-by: Yves Brissaud <[email protected]>
Signed-off-by: Yves Brissaud <[email protected]>
eunomie and others added 8 commits November 5, 2026 19:06
Signed-off-by: Yves Brissaud <[email protected]>
go-sdk v1.4.0 types every dependency's check as a Check in unified
bindings (dagger/go-sdk#83), so the Python, TypeScript and Elixir dry
runs now return one, as the Rust dry run already did. One helper turns a
failed check into the error the release report records.

Signed-off-by: Erik Sipsma <[email protected]>
Generated with `dagger generate go-sdk/generate`; a second run changes
nothing. v1.4.0 targets v1.0.0-beta.24 and writes a dang.toml beside each
generated entrypoint, naming that release. dagger.lock records the
v1.4.0 tag and the images and helpers it uses.

Signed-off-by: Erik Sipsma <[email protected]>
A generated entrypoint builds its module in the golang image its go.mod
names. The migrated modules named 1.26.1, 1.26.5 and 1.26.6, so a run
that calls several of them pulled three images and compiled into three
separate Go caches. They now all name 1.26.6, the version the root
module and the go, cli-dev and engine-dev modules already use.

Signed-off-by: Erik Sipsma <[email protected]>
main updated its module dependencies and the pytest module. Keep main's
lock pins where both sides pinned the same ref, and regenerate the
bindings that read pytest's and python-client-dev's API.

Signed-off-by: Erik Sipsma <[email protected]>
An entrypoint module pulls an image by tag in its own Dang code and in the
process it starts with nesting, which is how an SDK entrypoint runs a
module's code. Check that both get the digest the workspace lock pins for
that tag rather than the tag's current image.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma force-pushed the sipsma/go-modules-dang-entrypoint branch from a127b44 to ba44cd4 Compare November 5, 2026 19:22
The workspace's go-sdk scope for python-client-dev now sets
dangEntrypoint and unifiedClients to true, so the module gets a
generated Dang entrypoint and unified clients like the other Go modules.
Its pytest, engine-dev, wolfi and dockerd calls go through the generated
clients, and its own code uses dagger.io/dagger/core instead of the
global client.

The Format, Lint and LintDocsSnippets checks returned a changeset or a
container, which the engine refuses for a module without engineVersion.
They now return an error after syncing the same work, as the engine did
for them before, so they pass and fail as they did and the check list is
unchanged.

The manifest's dependencies become the scope's clients: pytest and
dagger.io/linux/wolfi resolve to the same commits the manifest pinned,
through the workspace lock. The provisioning test unsets
DAGGER_SESSION_PORT and DAGGER_SESSION_TOKEN, since execs nest on the v1
API. go.mod moves to Go 1.26.6 like the other modules.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma

sipsma commented Nov 10, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded by #15080, which merged all of this PR's commits: the repository's Go modules, python-client-dev included, now run through the go-sdk Dang entrypoint on main, and the lock regression test is there too. The remaining step, regenerating the modules on Go 1.27 with daggerGo once v1.0.0-beta.26 and a go-sdk release with dagger/go-sdk#100 are out, will open as a new PR then.

@sipsma sipsma closed this Nov 10, 2026
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