#dagger runs fine locally but not in a GH Action pipeline

1 messages · Page 1 of 1 (latest)

slim dawn
#

Here's a snippet of the logs. I'm lost - I worked on this yesterday for a long time and still can't get it to work. I did drop the 'with: module: demo' part from the GHA - either way same issue.

  • name: Run Dagger
    env:
    HOOK: "https://hooks.slack.com/services/xxxxxxxx"
    uses: dagger/dagger-for-github@v5
    with:
    workdir: ${{github.workspace}}/dagger_io/demo
    version: 0.11.6
    verb: functions
    args: send-slack-message --message frompipeline --webhook %HOOK%

13:32:06 INF Connected to engine name=5bc15fdd28fe version=v0.11.6
6 : connecting to engine DONE [2.1s]
7 : starting session
7 : starting session DONE [0.2s]
1 : connect DONE [8.5s]
8 : initialize
9 : ModuleSource.asModule: Module!
9 : ModuleSource.asModule: Module! ERROR [5.9s]
9 : ! 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 "/usr/local/bin/codegen --output /src --module-context-path /src/dagger_io/demo/dagger --module-name demo --introspection-json-path /schema.json" did not complete successfully: exit code: 1
8 : initialize ERROR [5.9s]
8 : ! 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 "/usr/local/bin/codegen --output /src --module-context-path /src/dagger_io/demo/dagger --module-name demo --introspection-json-path /schema.json" did not complete successfully: exit code: 1

proper wave
#

cc @loud hemlock any clues?

slim dawn
#

I puit the module: demo back and pinned everything to 0.11.6 - and same. current log: : [5.6s] | Status: Downloaded newer image for registry.dagger.io/engine:v0.11.6
4 : [5.6s] | registry.dagger.io/engine:v0.11.6
4 : exec docker pull registry.dagger.io/engine:v0.11.6 DONE [5.6s]
5 : exec docker run --name dagger-engine-32e0269fab8e9d98 -d --restart always -v /var/lib/dagger --privileged registry.dagger.io/engine:v0.11.6 --debug
5 : [0.0s] | c09c3dc2534fbca736fa2d5dc9d0e1153268b7cf0a5e0ac26f09215320d37563
5 : exec docker run --name dagger-engine-32e0269fab8e9d98 -d --restart always -v /var/lib/dagger --privileged registry.dagger.io/engine:v0.11.6 --debug DONE [0.3s]
2 : starting engine DONE [6.3s]
6 : connecting to engine
14:00:53 INF Connected to engine name=c09c3dc2534f version=v0.11.6
6 : connecting to engine DONE [2.1s]
7 : starting session
7 : starting session DONE [0.2s]
1 : connect DONE [8.6s]
8 : initialize
9 : ModuleSource.asModule: Module!
9 : ModuleSource.asModule: Module! ERROR [5.9s]
9 : ! 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 "/usr/local/bin/codegen --output /src --module-context-path /src/dagger_io/demo/dagger --module-name demo --introspection-json-path /schema.json" did not complete successfully: exit code: 1
8 : initialize ERROR [6.0s]
8 : ! 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 "/usr/local/bin/codegen --output /src --module-context-path /src/dagger_io/demo/dagger --module-name demo --introspection-json-path /schema.json" did not complete successfully: exit code: 1
Stdout:

prime snow
#

@slim dawn are you able to share a Trace via Dagger Cloud, so we can inspect it? You need a free Dagger Cloud account (dagger login), then add your dagger cloud API token to CI environment

slim dawn
#

I'll do my best to setup that up. I think I have an account and api - any special commands to issue in the pipeline or does the action handle it for me (like the dagger login?)

prime snow
#

all you have to do is authenticate the engine and it will start sending telemetry. No change to your code required.

slim dawn
#

sweet - on it - will repspond when done - thanks a million for the offer of help

prime snow
#

If you dagger login on your local machine it will start sending traces as well (no env variable needed). That way you can compare a working trace to a not-working trace

winter elk
#

Why is the verb set to functions instead of call?

Intentional?

#

You can omit verb and it will default to dagger call

loud hemlock
#

Yeah, the verb isn't right.

#

I wouldn't expect it to fail during codegen though.

#

What's in dagger_io/demo, is it from us?

slim dawn
#

sorry - got on a meeting...

#

ok - I'll set it to call - I was just trying to get it to output the functions. @winter elk

#

brb - let me try that

#

same with verb of call

#

here is the main.go from dagger_io/demo dir in my repo - it is not from you. I developed all of this - no laughing...I'm new to golang. @loud hemlock

#

// A generated module for Demo functions
//
// This module has been generated via dagger init and serves as a reference to
// basic module structure as you get started with Dagger.
//
// Two functions have been pre-created. You can modify, delete, or add to them,
// as needed. They demonstrate usage of arguments and return types using simple
// echo and grep commands. The functions can be called from the dagger CLI or
// from one of the SDKs.
//
// The first line in this comment block is a short description line and the
// rest is a long description with more detail on the module's purpose or usage,
// if appropriate. All modules should have a short description.

// err = slack.PostWebhook("https://hooks.slack.com/services/T1C1DRE91/xxxx", &msg)

package main

import (
"encoding/json"
"fmt"
"strconv"
"time"

"github.com/slack-go/slack"

)

type Demo struct{}

func (m *Demo) SendSlackMessage(message string, webhook string) {
if message == "" {
message = "<!channel> Hi From Dagger.io and GoLang"
}
attachment := slack.Attachment{
Color: "good",
Fallback: "You successfully posted by Incoming Webhook URL!",
AuthorName: "Bob Hoss",
AuthorSubname: "github.com",
Text: message,
Ts: json.Number(strconv.FormatInt(time.Now().Unix(), 10)),
}

msg := slack.WebhookMessage{
    Attachments: []slack.Attachment{attachment},
}

//err := slack.PostWebhook("https://hooks.slack.com/services/T1C1DRE91/xxxx", &msg)
err := slack.PostWebhook(webhook, &msg)
if err != nil {
    fmt.Println(err)
}

}

proper wave
#

@slim dawn is the dagger.json file in the demo folder? Or is it somewhere else in the project path?

slim dawn
#

a screenshot from vscode @proper wave

#

contents of dagger.json {
"name": "demo",
"sdk": "go",
"source": "dagger",
"engineVersion": "v0.11.6"
}

proper wave
# slim dawn

Thx mind sharing this screenshot again? For some reason it's unreadable for me

slim dawn
#

no worries...

#

if that doesn/t work... here's a dir

proper wave
#

Oh sorry, I meant the actions output terminal

slim dawn
#

roger

#

no worries!

#

any better?

proper wave
#

Yes, thx. Do you have more output after the stdout line at the bottom?

#

That might show where the error is coming from

slim dawn
#

Stdout:
generating go module: demo
writing dagger_io/demo/dagger/dagger.gen.go
writing dagger_io/demo/dagger/go.mod
writing dagger_io/demo/dagger/go.sum
creating directory dagger_io/demo/dagger/internal
creating directory dagger_io/demo/dagger/internal/dagger
writing dagger_io/demo/dagger/internal/dagger/dagger.gen.go
creating directory dagger_io/demo/dagger/internal/querybuilder
writing dagger_io/demo/dagger/internal/querybuilder/marshal.go
writing dagger_io/demo/dagger/internal/querybuilder/querybuilder.go
creating directory dagger_io/demo/dagger/internal/telemetry
writing dagger_io/demo/dagger/internal/telemetry/attrs.go
writing dagger_io/demo/dagger/internal/telemetry/batch_processor.go
writing dagger_io/demo/dagger/internal/telemetry/init.go
writing dagger_io/demo/dagger/internal/telemetry/processor.go
writing dagger_io/demo/dagger/internal/telemetry/proxy.go
writing dagger_io/demo/dagger/internal/telemetry/span.go
running post-command: go mod tidy
post-command failed: exit status 1
Stderr:
go: github.com/99designs/gqlgen@v0.17.44: Get "https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.44.mod": EOF
Error: exit status 1
Error: 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 "/usr/local/bin/codegen --output /src --module-context-path /src/dagger_io/demo/dagger --module-name demo --introspection-json-path /schema.json" did not complete successfully: exit code: 1

Stdout:
generating go module: demo
writing dagger_io/demo/dagger/dagger.gen.go
writing dagger_io/demo/dagger/go.mod

#

writing dagger_io/demo/dagger/go.sum
creating directory dagger_io/demo/dagger/internal
creating directory dagger_io/demo/dagger/internal/dagger
writing dagger_io/demo/dagger/internal/dagger/dagger.gen.go
creating directory dagger_io/demo/dagger/internal/querybuilder
writing dagger_io/demo/dagger/internal/querybuilder/marshal.go
writing dagger_io/demo/dagger/internal/querybuilder/querybuilder.go
creating directory dagger_io/demo/dagger/internal/telemetry
writing dagger_io/demo/dagger/internal/telemetry/attrs.go
writing dagger_io/demo/dagger/internal/telemetry/batch_processor.go
writing dagger_io/demo/dagger/internal/telemetry/init.go
writing dagger_io/demo/dagger/internal/telemetry/processor.go
writing dagger_io/demo/dagger/internal/telemetry/proxy.go
writing dagger_io/demo/dagger/internal/telemetry/span.go
running post-command: go mod tidy
post-command failed: exit status 1
Stderr:
go: github.com/99designs/gqlgen@v0.17.44: Get "https://proxy.golang.org/github.com/99designs/gqlgen/@v/v0.17.44.mod": EOF
Error: exit status 1

proper wave
#

Oh, interesting... Looks like a go proxy error fetching that dependency?

slim dawn
#

we do have a firewall on our github runners - I don't know about a proxy per se. I could try github hosted runners vs our self hosted.

proper wave
slim dawn
#

I'm pretty sure github.com would not be blocked but need to confirm

proper wave
#

I didn't realize that you were using a self hosted runners

slim dawn
#

yes - wasn't aware that would be different so long as it had access (aka whitelisted) - ok....golang may not be allowed.

#

good catch...

#

I see it now

proper wave
#

Maybe your company has an internal proxy or something.. that's quite common

#

Using GitHub hosted runners should work

slim dawn
#

no proxy - only allowed whitelisted fqdns.

#

I'll try the github hosted ones...will report back in

#

so for dagger.io and api.dagger.cloud - I had to have those whitelisted to work on our runners...makes sense.

#

ok - confirmed this is a self hosted runner vs github runner situation our firewall is blocking the golang proxy mentioned in the thread. UGH. This is like 2x's this has gotten me. Thanks for the help everyone!!

#

MANY MANY Thanks to all who helped!

prime snow
#

@slim dawn glad you could track it down! Are you stuck in your adoption of Dagger because of this?

#

how can we help

slim dawn
#

I wouldn't say stuck - but it was rough to figure out. I REALLY want to adopt Dagger.io here at the office. In fact I'm giving a demo of it next Friday to my tech org as I'm so excited about it.

#

I would like to know - per this article: https://stackoverflow.com/questions/71023129/module-lookup-disabled-by-goproxy-off-but-go-env-shows-goproxy-is-set you can turn off the GOPROXY - but I'm not sure how to get that into the GH Action yaml without modifying it which kind of defeats the idea of using the action. Because I 'think' the export GOPROXY=direct would have to be handled by the dagger/dagger-for-github@v5 action. @prime snow

prime snow
slim dawn
#

understood. It would be nice if it was a flag - something like GOPROXY: disable for the dagger/dagger-for-github@v5 action or something similar.

#
Software Engineer Tips And Tricks

To disable Go module proxy, you can use the following steps:

  1. Set the GOPROXY environment variable to "direct":

$ export GOPROXY=direct

This will instruct Go to use the modules directly from their source repositories, without going through any proxy.

  1. Optionally, you can unset any other related environment variables
prime snow
#

just to be sure, disabling go proxy still has the go tooling downloading dependencies from upstream git repos, that won't be blocked by your proxy?

#

if the goal is to "airgap" the loading of that module unfortunately disabling the go proxy won't be enough

slim dawn
#

we have github open - so I don't think that will be an issue. I'd have to test it obviously.

proper wave
#

I think there's a way to make this work with the default action. Currently on mobile,.will reply in a sec

prime snow
slim dawn
#

could be @prime snow , good thought. Thanks again for all the help and input!!!!!

proper wave
#

@slim dawn can you try adding

uses: dagger/dagger-for-github@v5
env:
  GO_PROXY: direct
  _DAGGER_ENGINE_SYSTEMENV_GOPROXY: direct

and see if that works? 🙏

slim dawn
#

on it!

proper wave
#

hmmm.. I think that won't work.. we're not automatically passing that variable in the engine startup from the CLI 😬

slim dawn
#

currently hangning here:

#

yup - something not right. Just sitting at the conecting to engine

proper wave
#

you can do the following as a temporary workaround:

- name: Start custom engine
  run:  docker run --name dagger-engine -e _DAGGER_ENGINE_SYSTEMENV_GOPROXY=direct -d --restart always -v /var/lib/dagger --privileged registry.dagger.io/engine:v0.11.6 --debug
- name: Build
  uses: dagger/dagger-for-github@v5
  env:
    _EXPERIMENTAL_DAGGER_RUNNER_HOST: docker-container://dagger-engine
  with:
    version: "latest"
    verb: call
    args: ......
#

the action currently doesn't support starting the engine with custom env variables and in this particular case we need to set the _DAGGER_ENGINE_SYSTEMENV.... so it picks the right goproxy

#

I'm already taking note of that to open an issue to address this in a better way

slim dawn
#

testing away - brb - and thanks for looking into this, very appreciated!

proper wave
#

the snippet above runs the engine manually with the correct env and then sets the _EXPERIMENTAL_DAGGER_RUNNER_HOST to that engine is used afterwards 🙏

slim dawn
#

makes sense - brb with results

proper wave
#

brb

slim dawn
proper wave
#

That's what Solomon was mentioning

#

Looks like the goproxy worked

#

And your firewall it's blocking it

slim dawn
#

yeah - exactly.

#

it would be nice to be able to turn off things like this for companies like us.

#

like why do I need opentelemetry.io - I wonder if that can be done....have to look

proper wave
#

If there's a way you could whitelist proxy.golang.org that'd be the best approach I think

slim dawn
#

totally cool - and makes 120% sense - it's not really dagger so much as it's golang so far as I can tell.

#

I can most likely get it whitelisted - good to know about all this though. I'm used to powershell - so go is all new to me as to how it needs things and so on.

proper wave
slim dawn
#

finding that out quickly, would python be a better choice of language for me in this case?

prime snow
proper wave
#

Come to think about it, "maybe" the python SDK doesn't need this given that it has a specialized code generation process. cc @loud hemlock will know for sure.

slim dawn
#

sounds good - I'm open to python - if he knows, I'll be curious.

loud hemlock
#

Yeah, Python's codegen is all python. Only depends on a python lib for graphql introspection.

#

But, all non-Go SDKs use a Go module for their runtime modules.

#

So atm you always run at least one Go module, even if you don't use any directly or as a dependency.

slim dawn
#

makes sense - so @loud hemlock , it sounds like I should try using Python as my sdk for now with as much firewall blocking as we have.

wet monolith
#

There’s an issue in our github repo, called Modules Break in Corporate Environments (im on a bad cell connection atm and can’t get gh to load).

In there the next steps are described, which is to support setting ca/proxy settings (including GOPROXY) set by the client, whereas right now they have to be set on the engine container. I think that’s part of what you want.

The problem of “arbitrary proxy settings” also is described somewhere in the issue. The idea is to give a mechanism for configuring arbitrary env vars on module containers. We started with just GOPROXY because it was by far the most common request but there’s paths to generalizing it.

proper wave
#

this imples that all Dagger SDK's will currently try to install some go dependencies as part of the bootstrapping phase

prime snow
#

@wet monolith sorry I didn't realize you were on vacation. enjoy!

slim dawn
#

Thanks all for the explanations!! This helps me understand. Thanks for taking the time to help and inform!

restive wing
#

can someone explain me how can i add GOPROXY on engine ? (docker)

proper wave
restive wing
#

no

proper wave
# restive wing no

ok, so in order for the engine to pick a GOPROXY, you need to set _DAGGER_ENGINE_SYSTEMENV_GOPROXY env variable when starting the engine