Skip to content

[backport-0.21] Pin otel-go and otel/sdk in generated Go modules - #14646

Merged
eunomie merged 8 commits into
backport-0.21from
backport-0.21-pin-codegen-otel-deps
Oct 21, 2026
Merged

eunomie merged 8 commits into
backport-0.21from
backport-0.21-pin-codegen-otel-deps

Conversation

@eunomie

@eunomie eunomie commented Oct 13, 2026

Copy link
Copy Markdown
Member

[backport-0.21] Pin otel-go and otel/sdk in generated Go modules

Backport of #14450 (dc03a9e) to backport-0.21.

What broke

On v0.21.x, Go module codegen fails with:

imports go.opentelemetry.io/otel/log from logger.go
imports go.opentelemetry.io/otel/internal/global from keyvalue.go: import cycle not allowed

It fails on every new dagger init --sdk=go, and on any module whose go.mod does not already require go.opentelemetry.io/otel/sdk.

Why

Generated code imports github.com/dagger/otel-go and go.opentelemetry.io/otel/sdk/resource. Codegen copies sdk/go/go.mod into the module, and that file requires neither, so go mod tidy resolves both at their latest versions. Since 2026-10-02, latest means otel v1.47.0, whose internal/global imports otel/log. Codegen also copies the otel/log => v0.16.0 replace, and v0.16.0 imports otel/internal/global. Together they form the cycle.

Fix

  • Cherry-pick dc03a9e: the tools-tagged sdk/go/internal/codegendeps package makes codegen pin otel-go v1.43.0 and otel/sdk v1.43.0, as v1.0.0-beta.16 and later already do.
  • Add a regression test on syncModReplaceAndTidy.
  • Add a changelog fragment.

Codegen never downgrades, so modules already generated with otel v1.47.0 keep that version. To fix such a module, run:

go get go.opentelemetry.io/[email protected] go.opentelemetry.io/otel/[email protected]

Verification

  • The new test fails without the cherry-pick and passes with it.
  • The cmd/codegen/generator/go and sdk/go tests pass.
  • go mod tidy -diff is clean for sdk/go and for the root module.
  • I replayed the codegen go.mod steps in scratch modules with Go 1.26 (seed requires, replaces, go get dagger.io/dagger, go mod tidy, go build):
    • v0.21.10 reproduces the cycle.
    • This branch builds.
    • The go get above repairs an already broken module.
  • Not run: engine e2e.

sipsma and others added 4 commits October 13, 2026 14:21
Code generated for Go modules imports github.com/dagger/otel-go and
go.opentelemetry.io/otel/sdk, but this SDK didn't require them. Module
codegen copies the SDK's requirements into each generated module's
go.mod, so `go mod tidy` there had to look up which module provides each
of those imports over the network, and then picked whatever version was
newest at the time.

Require them through a tools-tagged package, so codegen pins them like
the SDK's other dependencies. The tag keeps them out of builds.

Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit dc03a9e)
Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie marked this pull request as ready for review October 13, 2026 12:47
@eunomie
eunomie requested a review from a team as a code owner October 13, 2026 12:47
A fresh client module only required dagger.io/dagger. When tidy
resolved its direct imports, it could select the newest OTel release
instead of the versions used by the SDK. Importing that client from
a Dagger module then conflicted with the pinned OTel log package.

Seed new client modules with the embedded SDK requirements before
running tidy. Preserve existing client modules and their chosen
versions. Add a test for the initial module requirements.

Signed-off-by: Tibor Vass <[email protected]>
(cherry picked from commit 7eddc48)
Signed-off-by: Yves Brissaud <[email protected]>
crazymax/goxx:latest moved to Go 1.27, where golang.org/x/net v0.54.0
no longer defines http2.TrailerPrefix, so grpc v1.80.0 fails to build.

Signed-off-by: Yves Brissaud <[email protected]>
The test binds a consumer exec to app, and app to dep, and asserts that
dep's exit reaches the consumer through app as "bound service <app>
exited: ... bound service <dep> exited: exit code: 42". dep ran
"sleep 1; exit 42" with no gate, so when app's startup took longer than
1s the service start loop took its other designed branch and failed
app's start with "start <app> (aliased as app): bound service <dep>
(aliased as dep) exited", which the test does not accept.

Make the ordering causal instead of timing-based. The consumer's command
touches a marker on a per-run shared cache volume, and dep exits 42 only
once that marker exists. By then app has been returned as running and
the consumer's bound-service monitor is installed. dep's watchdog exits
1, not 42, if the marker never appears. app now loops until killed
instead of sleeping 30s, so it cannot exit on its own while a slow
consumer is still setting up. The consumer is still not bound to dep,
and the assertions are unchanged.

Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 70c1201)
Signed-off-by: Yves Brissaud <[email protected]>
The test-split:test-telemetry CI trace showed the TypeScript fail-effect golden differing only by a transient packet-loss suffix on the failed span: ERROR (5.88% dropped).

That metric reflects ephemeral network conditions in the test environment rather than the progress-rendering behavior the golden is asserting. Normalize packet-loss adornments in the shared scrubber and add focused coverage for the failing shape.

Signed-off-by: Erik Sipsma <[email protected]>
(cherry picked from commit 889d043)
Signed-off-by: Yves Brissaud <[email protected]>
@eunomie
eunomie merged commit 092a164 into backport-0.21 Oct 21, 2026
76 checks passed
@eunomie
eunomie deleted the backport-0.21-pin-codegen-otel-deps branch October 21, 2026 12:34
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