Skip to content

Tests require disabling go mod index pending upstream bug fix #8031

Closed

Description

@sipsma

I saw this flake on main (Traces) and got very sad since it was in TestLegacy which should have been fixed.

But this flake appears to be distinct from the old one, even though part of the error message is the same:

  1. The mismatch in files occurs in TestLegacyExportAbsolutePath and crucially is in internal/dagger/dagger.gen.go rather than in go.mod
  2. Looking through the engine logs from that run, I can see that filesync cache refs are not being re-used between different client sessions, which was the important part of the root cause for the other flake
  3. I could repro the previous flake locally by running TestLegacy in a loop for at most an hour (but usually closer to 20m). But I have been running that same loop on main for going on 3 hours now locally with it passing every time (takes about 45s per run).

The error this time looks like

	Error Trace:	/app/core/integration/legacy_test.go:62
	Error:      	Received unexpected error:
	            	input: container.from.withMountedFile.withWorkdir.withExec.withNewFile.withNewFile.withExec.stdout resolve: process "dagger --debug query" did not complete successfully: exit code: 1
	            	
	            	Stderr:
	            	Error: failed to serve module: input: module.withSource.initialize resolve: failed to initialize module: failed to call module "bare" to get functions: call constructor: process "go build -o /runtime ." did not complete successfully: exit code: 1
	            	
	            	Stderr:
	            	internal/dagger/dagger.gen.go:23:2: package dagger/test/internal/querybuilder is not in std (/usr/local/go/src/dagger/test/internal/querybuilder)
	            	internal/dagger/dagger.gen.go:24:2: package dagger/test/internal/telemetry is not in std (/usr/local/go/src/dagger/test/internal/telemetry)
	Test:       	TestLegacy/TestLegacyExportAbsolutePath

I spent a while pouring through the engine logs to find any clues, but everything checks out and looks expected from what I can see based on what we include there.

I don't have any strong hunches yet, but a couple things to note/investigate:

  1. Not clear yet how often this happens, just saw it this one time. Can't repro locally so will just have to see what happens in CI
  2. When running the test loop locally I checked the kernel logs at one point and saw that 10m earlier there was a single [211550.735848] overlayfs: lowerdir is in-use as upperdir/workdir of another mount, accessing files from both mounts will result in undefined behavior.
    • No idea what to make of this yet, could be completely unrelated. But there must be some rare bug somewhere between buildkit+dagger that causes invalid mounts to be created, which could plausibly explain a situation like this
    • I may go re-enable printing kernel logs in CI again since this is the exact type of situation where they could be extremely useful
  3. Possible places things could be going wrong (completely hypothetical at this point)
    • Some deep bug in overlay mount setup (just based on that kernel log mentioned above)
    • File export somehow getting confused and routing files to the wrong client/session (but just some files, not sure how that could happen)

Activity

  1. added
    kind/bug
    area/engine
    on Jul 24, 2024
  2. jedevc commented on Jul 31, 2024

    @jedevc
    Contributor

    Hmmmm, maybe this isn't the same, but I do occasionally see this one too: https://dagger.cloud/dagger/traces/8e10dd9a4a2016f2a739f4831b47879d?span=90b732664b3eb8a9#90b732664b3eb8a9:L12

    	Error Trace:	/app/core/integration/module_test.go:54
    	            				/app/testctx/testctx.go:163
    
    	Error:      	Received unexpected error:
    	            	input: container.from.withMountedFile.withWorkdir.withExec.withExec.stdout resolve: process "dagger --debug query" did not complete successfully: exit code: 
    
    	            	Stderr:
    
    	            	Error: failed to serve module: input: moduleSource.withContextDirectory.asModule resolve: failed to create module: select: failed to update codegen and runtime: failed to generate code: failed to get modified source directory for go module sdk codegen: select: process "codegen --output /src --module-context-path /src --module-name bare --introspection-json-path /schema.json" did not complete successfully: exit code: 1
    
    	            	
    	            	Stdout:
    	            	generating go module: bare
    	            	writing dagger.gen.go
    	            	writing go.mod
    	            	writing go.sum
    	            	running post-command: go mod tidy
    	            	needs another pass...
    
    	            	Stderr:
    	            	Error: generate code: template: module.go.tmpl:79:3: executing "_dagger.gen.go/module.go.tmpl" at <ModuleMainSrc>: error calling ModuleMainSrc: cannot find default codegen DaggerObject interface
    	Test:       	TestModule/TestGoInit/from_scratch
    

    This could potentially be occurring if we were getting the wrong main.go for a specific test? Maybe?

  3. sipsma commented on Aug 30, 2024

    @sipsma
    ContributorAuthor

    I managed to repro this in CI with a sleep added so I could nsenter into the container and found what seems like it must be a bug in go's build caching?

    fail to build due to an import not being found:

    buildkitsandbox:/src# /usr/local/go/bin/go build -o /runtime .
    internal/dagger/dagger.gen.go:23:2: package dagger/bare/internal/querybuilder is not in std (/usr/local/go/src/dagger/bare/internal/querybuilder)
    internal/dagger/dagger.gen.go:24:2: package dagger/bare/internal/telemetry is not in std (/usr/local/go/src/dagger/bare/internal/telemetry)
    

    But when looking at the file it's erroring on, the lines it's complaining about don't match the error at all:

    buildkitsandbox:/src# head -n 100 internal/dagger/dagger.gen.go 
    // Code generated by dagger. DO NOT EDIT.
    
    package dagger
    
    import (
            "context"
            "encoding/json"
            "errors"
            "fmt"
            "net"
            "net/http"
            "os"
            "reflect"
            "strconv"
            "strings"
    
            "github.com/Khan/genqlient/graphql"
            "github.com/vektah/gqlparser/v2/gqlerror"
            "go.opentelemetry.io/otel"
            "go.opentelemetry.io/otel/propagation"
            "go.opentelemetry.io/otel/trace"
    
            "dagger/test/internal/querybuilder"
            "dagger/test/internal/telemetry"
    )
    

    Then, rm -rf the whole go build cache and now it magically builds again!!

    buildkitsandbox:/src# rm -rf /root/.cache/go-build/*
    buildkitsandbox:/src# /usr/local/go/bin/go build -o /runtime .
    

    I don't really see how this could be anything but a bug in go.

    It wouldn't shock me if it was something vaguely similar to the problem we had with filesync file comparisons that relied on comparing file size + timestamps rather than digesting all the contents: that would explain why go appears to be confusing test and bare

    • This is just speculation, but those sorts of heuristics are both relatively common and obviously have already bitten us in the past

    Next steps:

    • repro again but this time tar up the whole build cache and /src dir so we can try to find a minimal repro for the go team to open an issue
    • think about what mitigations might be possible in the meantime
      • changing the cache mount to locked might be worth a try, though no guarantees it would fix; would also be a user-facing performance hit
      • doing something like touching file timestamps that avoids the problem somehow (vague idea, needs more thought)

    cc @jedevc you're gonna love this one 😄

  4. changed the title [-](Another different) `TestLegacy` flake[/-] [+]Test flake: package dagger/<modname>/internal/querybuilder is not in std [/+] on Aug 30, 2024
  5. sipsma commented on Aug 30, 2024

    @sipsma
    ContributorAuthor

    Okay managed to repro in CI again, tar up the whole rootfs, upload to s3 to exfiltrate it out, and then turn into a docker image that reproduces the problem at eriksipsma/corrupt-cache:latest in dockerhub (it's an amd64 image only since that's what our CI is).

    Build failure:

    sipsma@dagger_dev:~$ docker run --rm -it eriksipsma/corrupt-cache:latest sh -c '/usr/local/go/bin/go build -C /src .'
    go: downloading go.opentelemetry.io/otel v1.27.0
    go: downloading go.opentelemetry.io/otel/sdk v1.27.0
    go: downloading go.opentelemetry.io/otel/trace v1.27.0
    go: downloading github.com/99designs/gqlgen v0.17.49
    go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
    go: downloading github.com/Khan/genqlient v0.7.0
    go: downloading golang.org/x/sync v0.7.0
    go: downloading github.com/vektah/gqlparser/v2 v2.5.16
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
    go: downloading go.opentelemetry.io/otel/log v0.3.0
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
    go: downloading go.opentelemetry.io/otel/sdk/log v0.3.0
    go: downloading go.opentelemetry.io/proto/otlp v1.3.1
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0
    go: downloading google.golang.org/grpc v1.64.0
    go: downloading github.com/go-logr/logr v1.4.1
    go: downloading go.opentelemetry.io/otel/metric v1.27.0
    go: downloading golang.org/x/sys v0.21.0
    go: downloading google.golang.org/protobuf v1.34.1
    go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291
    go: downloading github.com/go-logr/stdr v1.2.2
    go: downloading github.com/cenkalti/backoff/v4 v4.3.0
    go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
    go: downloading github.com/google/uuid v1.6.0
    go: downloading github.com/sosodev/duration v1.3.1
    go: downloading golang.org/x/net v0.26.0
    go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5
    go: downloading golang.org/x/text v0.16.0
    internal/dagger/dagger.gen.go:23:2: package dagger/test/internal/querybuilder is not in std (/usr/local/go/src/dagger/test/internal/querybuilder)
    internal/dagger/dagger.gen.go:24:2: package dagger/test/internal/telemetry is not in std (/usr/local/go/src/dagger/test/internal/telemetry)
    

    The errors do not correspond to the actual contents of the file:

    sipsma@dagger_dev:~$ docker run --rm -it eriksipsma/corrupt-cache:latest head -n25 /src/internal/dagger/dagger.gen.go
    // Code generated by dagger. DO NOT EDIT.
    
    package dagger
    
    import (
            "context"
            "encoding/json"
            "errors"
            "fmt"
            "net"
            "net/http"
            "os"
            "reflect"
            "strconv"
            "strings"
    
            "github.com/Khan/genqlient/graphql"
            "github.com/vektah/gqlparser/v2/gqlerror"
            "go.opentelemetry.io/otel"
            "go.opentelemetry.io/otel/propagation"
            "go.opentelemetry.io/otel/trace"
    
            "dagger/bare/internal/querybuilder"
            "dagger/bare/internal/telemetry"
    )
    

    Removing the go build cache first results in the errors going away and a successful build:

    sipsma@dagger_dev:~$ docker run --rm -it eriksipsma/corrupt-cache:latest sh -c 'rm -rf /root/.cache/go-build && /usr/local/go/bin/go build -C /src .'
    go: downloading go.opentelemetry.io/otel/sdk v1.27.0
    go: downloading go.opentelemetry.io/otel/trace v1.27.0
    go: downloading go.opentelemetry.io/otel v1.27.0
    go: downloading github.com/99designs/gqlgen v0.17.49
    go: downloading github.com/Khan/genqlient v0.7.0
    go: downloading golang.org/x/exp v0.0.0-20231110203233-9a3e6036ecaa
    go: downloading golang.org/x/sync v0.7.0
    go: downloading github.com/vektah/gqlparser/v2 v2.5.16
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploggrpc v0.0.0-20240518090000-14441aefdf88
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlplog/otlploghttp v0.3.0
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.27.0
    go: downloading go.opentelemetry.io/otel/log v0.3.0
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.27.0
    go: downloading go.opentelemetry.io/otel/sdk/log v0.3.0
    go: downloading go.opentelemetry.io/proto/otlp v1.3.1
    go: downloading go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.27.0
    go: downloading google.golang.org/grpc v1.64.0
    go: downloading github.com/go-logr/logr v1.4.1
    go: downloading go.opentelemetry.io/otel/metric v1.27.0
    go: downloading golang.org/x/sys v0.21.0
    go: downloading google.golang.org/protobuf v1.34.1
    go: downloading google.golang.org/genproto/googleapis/rpc v0.0.0-20240515191416-fc5f0ca64291
    go: downloading github.com/google/uuid v1.6.0
    go: downloading github.com/sosodev/duration v1.3.1
    go: downloading github.com/go-logr/stdr v1.2.2
    go: downloading github.com/cenkalti/backoff/v4 v4.3.0
    go: downloading github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0
    go: downloading golang.org/x/net v0.26.0
    go: downloading google.golang.org/genproto/googleapis/api v0.0.0-20240520151616-dc85e6b867a5
    go: downloading golang.org/x/text v0.16.0
    
    • If your docker host is not amd64, this often fails with qemu related segfaults but eventually passes, not relevant to the problem here

    Gonna take that and open an issue on the Go repo now

  6. sipsma commented on Aug 30, 2024

    @sipsma
    ContributorAuthor

    Issue in go repo: golang/go#69179

  7. added
    kind/flake
    on Oct 10, 2024
  8. sipsma commented on Oct 10, 2024

    @sipsma
    ContributorAuthor

    This one is not causing a flake anymore after #8470 was merged. However, it's worth leaving open since it's fixed by disabling the go mod index in our test suite, which is really just a bandaid. Will rename to indicate it's tracking the upstream fix in Go and remove the flake label for now. Can close the issue once that bandaid is no longer needed.

  9. changed the title [-]Test flake: package dagger/<modname>/internal/querybuilder is not in std [/-] [+]Tests require disabling go mod index pending upstream bug fix[/+] on Oct 10, 2024
  10. removed
    kind/flake
    on Oct 10, 2024
  11. sipsma commented on Oct 30, 2024

    @sipsma
    ContributorAuthor

    We got a report of users hitting this now. We haven't noticed any downsides to disabling goindex in our CI so it's worth considering making this the default setting now. Also worth a double check on performance impact while doing so, especially since we have more metrics to make an informed decision.

  12. daniel-naegele commented on Jun 23, 2025

    @daniel-naegele

    I am experiencing a variant of this issue and am able to reproduce this I think. With the recent fix of #10612 I am finally able to run our dagger pipeline on GitLab CI and am only experiencing this issue on GitLab CI (using docker in docker executor).

    go.go:

    package main
    
    import (
    	"context"
    	"dagger/p3oc/internal/dagger"
    )
    
    func (m *P3oC) GoBuild(ctx context.Context,
    	// +defaultPath="src/"
    	source *dagger.Directory,
    ) *dagger.File {
    	const binaryPath = "/work/out/binary"
    
    	buildContainer := getBuildContainer(ctx, source).
    		WithExec([]string{"go", "build", "-o", binaryPath})
    
    	return buildContainer.File(binaryPath)
    }
    
    func getBuildContainer(ctx context.Context, source *dagger.Directory) *dagger.Container {
    	buildContainer := dag.Container().
    		From("golang:1.23.8"). // same version as in go.mod of dagger module, but latest produces the same result
    		WithMountedDirectory("/work", source).
    		WithWorkdir("/work")
    	goModContents, err := buildContainer.File("go.mod").Contents(ctx)
    	if goModContents != "" && err == nil {
    		buildContainer = buildContainer.WithExec([]string{"go", "mod", "download"})
    	}
                                                   // Adding this command does NOT solve the problem
    	return buildContainer.WithExec([]string{"rm", "-rf", "/root/.cache/go-build"})
    }

    base.go:

    package main
    
    import (
    	"context"
    	"dagger/p3oc/internal/dagger"
    	"errors"
    	"fmt"
    )
    
    func (m *P3oC) CheckStyle(
    	ctx context.Context,
    	// +defaultPath="."
    	source *dagger.Directory,
    	// +optional
    	ciCommitTag string,
    ) (string, error) {
    	result := yamlLint(ctx, source)
    
    	if ciCommitTag != "" {
    		helmVersion, err := dag.Container().
    			From("mikefarah/yq").
    			WithMountedDirectory("/workdir", source).
    			WithExec([]string{"yq", "-r", ".version", "Chart.yaml"}).
    			Stdout(ctx)
    
    		if err != nil {
    			return "Could not parse helm version", err
    		}
    
    		if helmVersion != ciCommitTag {
    			errStr := fmt.Sprintf("The chart version [%s] does not match the tag version [%s], please define it within the Chart.yaml file", helmVersion, ciCommitTag)
    			return result, errors.New(errStr)
    		}
    	}
    
    	return result, nil
    }
    
    func yamlLint(ctx context.Context, source *dagger.Directory) string {
    	// ignore errors
    	result, _ := dag.Container().
    		From("contane/yamllint").
    		WithMountedDirectory("/data", source).
    		WithExec([]string{"yamllint", "."}).
    		Stdout(ctx)
    
    	return result
    }

    .gitlab-ci.yml

    # Define base images
    .docker:
      image: docker:latest
      services:
        - docker:${DOCKER_VERSION}-dind
      variables:
        DOCKER_HOST: tcp://docker:2375
        DOCKER_TLS_CERTDIR: ""
        DOCKER_DRIVER: overlay2
        DOCKER_VERSION: "27.2.0"
    
    .dagger:
      extends: [.docker]
      before_script:
        - apk add curl
        # TODO make this a prebuilt container for faster build times
        - curl -fsSL https://dl.dagger.io/dagger/install.sh | DAGGER_COMMIT=head BIN_DIR=/usr/local/bin sh
        - export MODULE_URL="..."
        - echo -e "https://gitlab-ci-token:[email protected]" > ~/.git-credentials
        - git config --global credential.helper store
        - dagger version
    
    style:
      extends: [.dagger]
      stage: prepare
      script:
        - dagger call -m "$MODULE_URL" check-style --ci-commit-tag=$CI_COMMIT_TAG
     
    golangbuild:
      extends: [.dagger]
      stage: build
      script: dagger call -m "$MODULE_URL" go-build -o $CI_PROJECT_DIR/bin/$CI_PROJECT_NAME
      artifacts:
        when: on_success
        paths:
          - bin 

    If I execute either of those Dagger functions locally (also with the HEAD version), both work flawlessly. However, in the GitLab CI, the style job succeeds, while the golangbuild job fails with the following log. If base.go actually contained erroneous code, the style job should fail as well, but it is only the golangbuild job only in the GitLab CI environment.

    41 : $ dagger version
    42 : dagger v0.18.11-250623114550-8f3c84f5b22b (docker-image://registry.dagger.io/engine:8f3c84f5b22b4fb3626f942e155b7082be93af3d) linux/amd64
    ...
    47  : Container.file ERROR [26.9s]
    47  : ! process "go build -o /work/out/binary" did not complete successfully: exit code: 1
    
    1   : go-build -o /builds/kit/cm/members/bama/banaegele/pppoc/bin/pppoc
    40  : ┆ P3OC.goBuild ERROR [29.9s]
    40  : ┆ ! process "go build -o /work/out/binary" did not complete successfully: exit code: 1
    1   : go-build -o /builds/kit/cm/members/bama/banaegele/pppoc/bin/pppoc
    1   : [28s] | Error: input: p3OC.goBuild process "go build -o /work/out/binary" did not complete successfully: exit code: 1
    1   : [28s] | Stderr:
    1   : [28s] | base.go:5:2: package dagger/p3oc/internal/dagger is not in std (/usr/local/go/src/dagger/p3oc/internal/dagger)
    1   : go-build -o /builds/kit/cm/members/bama/banaegele/pppoc/bin/pppoc ERROR [28s]
    1   : ! exit code 1
    
    Setup tracing at https://dagger.cloud/traces/setup. To hide set DAGGER_NO_NAG=1
    
    Error: input: p3OC.goBuild process "go build -o /work/out/binary" did not complete successfully: exit code: 1
    Stderr:
    base.go:5:2: package dagger/p3oc/internal/dagger is not in std (/usr/local/go/src/dagger/p3oc/internal/dagger)
    

    Is there a workaround for this? As can be concluded from the code, no caching, for example for the go cache is used. Also using the latest go docker container does not fix that.

  13. locked and limited conversation to collaborators on Mar 24, 2026
  14. converted this issue into a discussion #12273 on Mar 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/ciarea/enginekind/bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions