Skip to content

Cannot find default codegen DaggerObject interface #8207

Closed

Description

@jedevc

Splitting out this one from #8031 (comment) to debug - it's quite clearly a different issue.

The first step towards understanding this was attempted in #8181, and now we have a few failure with this in TestModule/TestGoInit/from_scratch:

generating go module: bare
writing dagger.gen.go
writing go.mod
writing go.sum
running post-command: go mod tidy
needs another pass...

Error: generate code: template: module.go.tmpl:79:3: executing "_dagger.gen.go/module.go.tmpl" at <ModuleMainSrc>: error calling ModuleMainSrc: exected DaggerObject to be *types.Interface, but got *types.Basic

This is bizarre, DaggerObject is not a basic type, it's an interface - need to investigate more - I suspect that it's an unknown type (which is a basic type for some reason).

Opened #8214 to try and narrow down the possibilities:

  • Is is actually an unknown type?
  • Do internal/ packages actually exist at the time of the bad dagger call? And do they have the expected contents?
  • Are internal/ files getting weirdly regenerated by go formatting of imports?

Potentially, we're hitting something really weird, and causing some weird race condition in the go build cache? Otherwise, really stretching to imagine what could possibly be going on.

Note - this doesn't look like something in the dagger engine going wrong, like confusing the caching on different sets of files, we're actually running all of this within a single codegen pass.

Activity

  1. jedevc commented on Aug 22, 2024

    @jedevc
    ContributorAuthor

    Hm, just noticed that the places that this flakes in corresponds to where we use the go sdk with --name=bare pretty clearly - TestGit and TestGoInit.

  2. added
    kind/bug
    on Aug 27, 2024
  3. sipsma commented on Aug 29, 2024

    @sipsma
    Contributor

    Made some minor progress with this:

    1. It took absolutely forever to repro in my debugging PR when I was just re-running every engine test workflow over and over (i.e. re-running all engine tests suites in parallel)
      • BUT it seems to repro much easier if I instead push an empty commit, which triggers every workflow (including non-engine-test ones)...
      • Aligns with this possibly being some sort of race condition that's more likely to happen when the engine's host is under extra load? Otherwise I don't see how other workflows could be related
    2. Repro'd in CI with a sleep put in the code when this error gets hit which let me nsenter into the container and look around at the files to see if they were wrong or corrupted, did not notice anything off yet: https://gist.github.com/sipsma/64d3cb3fcb5e4bb868984c5fbb16bc02
    3. With that repro above, a ton of other tests also hit the error, all of them seeming to be modules with the name "test" https://dagger.cloud/dagger/traces/1dc589522f5b257ad5edbd27070d9b44
      • Sounds similar to what you saw with tests using the module name "bare" hitting this simultaneously @jedevc
      • Don't know what to make of this yet. As mentioned above, I didn't see that any file contents were incorrect.
      • One thing I'm going to try: see if this is reproducible with go mod cache + go build cache not on a shared cache volume. All these modules have the same module name, so like Justin mentioned in the issue description above, wouldn't rule out something being broken here
    4. I was looking through golang/go issues; did not find any exact matches but I did find some pretty recent issues for bugs in this general area around type aliases (which are relevant since DaggerObject goes through two levels of type aliasing before it gets to the "real" definition)
  4. jedevc commented on Aug 29, 2024

    @jedevc
    ContributorAuthor

    More verbosity reveals https://dagger.cloud/dagger/traces/afb638a78986ca43d0e8a8bb1e975f48#a732981c3df31b7e:L49:

    Stdout:
    generating go module: test
    creating directory . [skipped]
    writing dagger.gen.go
    writing go.mod
    writing go.sum
    creating directory internal [skipped]
    creating directory internal/dagger [skipped]
    writing internal/dagger/dagger.gen.go [skipped]
    creating directory internal/querybuilder [skipped]
    writing internal/querybuilder/marshal.go [skipped]
    writing internal/querybuilder/querybuilder.go [skipped]
    creating directory internal/telemetry [skipped]
    writing internal/telemetry/attrs.go [skipped]
    writing internal/telemetry/env.go [skipped]
    writing internal/telemetry/exporters.go [skipped]
    writing internal/telemetry/init.go [skipped]
    writing internal/telemetry/live.go [skipped]
    writing internal/telemetry/logging.go [skipped]
    writing internal/telemetry/proxy.go [skipped]
    writing internal/telemetry/span.go [skipped]
    writing internal/telemetry/transform.go [skipped]
    running post-command: go mod tidy
    needs another pass...
    Stderr:
    Error: generate code: template: module.go.tmpl:85:3: executing "_dagger.gen.go/module.go.tmpl" at <ModuleMainSrc>: error calling ModuleMainSrc: exected DaggerObject to be *types.Interface, but got *types.Basic (dagger/test/internal/dagger.DaggerObject)
    

    I screwed up the type to print out, so updated it in #8267.

    But at least, this reveals we did write the right internal/dagger/dagger.gen.go file. It's not something insane like the file doesn't get written.

    see if this is reproducible with go mod cache + go build cache not on a shared cache volume

    This is a good idea - especially given findings around the Python uv stuff, it doesn't seem impossible that this could be a new issue. Very much hoping it's not this, but at least might give us more of a hint and we could try and repro with more native go tooling.

  5. sipsma commented on Aug 29, 2024

    @sipsma
    Contributor

    I decided to try a few things before resorting to trying to disable the cache volume. Main reason being that disabling that is likely to slow things down so much that A) it will take forever to get enough runs to know if it actually fixed the problem B) it should be avoided at all costs as a solution due to the performance hit.

    Things I'm trying first:

    1. Currently - upgrading golang/x/tools to the latest version (v0.22 -> v0.24)
    2. If that doesn't work, try simplifying the level of type aliases we have setup (on the hunch there's a bug in the tooling due to our multi-level aliasing)
  6. sipsma commented on Aug 30, 2024

    @sipsma
    Contributor

    Merged the update to x/tools, have not seen the same error since across 5+ runs. Not gonna declare certain victory yet, which would displease the gods, but maybe it was a bug in that library afterall?

    Interestingly, I did hit different errors we used to see from time to time but personally I haven't hit in a few weeks: https://dagger.cloud/dagger/traces/6031bb6348e5b78863ccd386abe7076a

    A few tests there failing with errors like:

    	            	Error: failed to generate code: input: moduleSource.withName.withSDK.withInit.withSourceSubpath.resolveFromCaller resolve: failed to collect local module source deps: failed to load sdk: failed to load embedded sdk module "python": select: failed to initialize module: failed to call module "python-sdk" 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/foo/internal/querybuilder is not in std (/usr/local/go/src/dagger/foo/internal/querybuilder)
    	            	internal/dagger/dagger.gen.go:24:2: package dagger/foo/internal/telemetry is not in std (/usr/local/go/src/dagger/foo/internal/telemetry)
    

    So I wonder if the dep upgrade fixed/tweaked something and just unlocked a different problem? Hopefully I can repro this one again soon with a sleep in place so I can jump into the container and look at what's going wrong.

  7. sipsma commented on Aug 30, 2024

    @sipsma
    Contributor

    Ah, nevermind, still saw that error on main: https://dagger.cloud/dagger/traces/c5bc486ce9aa76ed770a877301119cd4?span=858b61b06da1ffe4

    Falling back to seeing if simplifying the multi-level aliasing avoids it.

  8. sipsma commented on Aug 30, 2024

    @sipsma
    Contributor

    I managed to find what looks like definitive proof of a bug in go build caching for these separate flakes: #8031 (comment)

    Could be unrelated to these ones, but wouldn't shock me if it is the same or similar root cause

  9. jedevc commented on Sep 5, 2024

    @jedevc
    ContributorAuthor

    This seems to have miraculously disappeared. I guess #8289 massaged things every so slightly, and the issue went away.

    🎉 worrying, but oh well, hopefully this is similar-enough to the upstream go issue 👀

  10. added
    kind/flake
    on Oct 10, 2024
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/cikind/bugkind/flake

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions