#Error: Dagger Functions in GitLab CI โ€”> Wrong socket

1 messages ยท Page 1 of 1 (latest)

flat surge
#

Hey ๐Ÿ‘‹ ,
I need your help. I want to run my GitLab Pipeline with a Dagger function.
I get the attached error.
My GitLab yml looks like this:

.docker:
  image: alpine:latest
  services:
    - docker:${DOCKER_VERSION}-dind
  variables:
    DOCKER_HOST: tcp://tcp:2376
    DOCKER_TLS_VERIFY: '1'
    DOCKER_TLS_CERTDIR: '/certs'
    DOCKER_CERT_PATH: '/certs/client'
    DOCKER_DRIVER: overlay2
    DOCKER_VERSION: '20.10.16'
    DAGGER_CLOUD_TOKEN: $DAGGER_CLOUD_TOKEN
.dagger:
  extends: [.docker]
  before_script:
    - apk add docker-cli curl
    - curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sh
build:
  tags:
    - dind
  extends: [.dagger]
  script:
    - dagger install github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0
    - dagger -m github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0 call hello

As I can see the first step installing the dagger module is ok.
After executing Dagger with the module I get the error.

If I add a variable _EXPERIMENTAL_DAGGER_RUNNER_HOST: tcp://dagger-engine:1234
I get another error: connect ERROR: new client: context deadline exceeded

build:
  tags:
    - dind
  extends: [.dagger]
  variables:
    _EXPERIMENTAL_DAGGER_RUNNER_HOST: tcp://dagger-engine:1234
  script:
    - dagger install github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0
    - dagger -m github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0 call hello
#

Error: Dagger Functions in GitLab CI โ€”> Wrong socket

digital sable
#

Hey @flat surge!! I cant currently test it myself and I'm not Gitlab CI expert. Comparing your setup to https://docs.dagger.io/user-guide/ci/734201-gitlab I see that the DOCKER_HOST is set to tcp://tcp:2376, while on the guide it says tcp://docker:2376, not sure exactly how things are started up but maybe the other host does not like it? It seems to be related to not having the docker daemon properly configured. Can you try with a setup that is like the one on the guide? Happy to debug with you if it does not work!

The following code sample demonstrates how to integrate Dagger with GitLab CI.

flat surge
# digital sable Hey <@960764294851608606>!! I cant currently test it myself and I'm not Gitlab C...

Updatet to:

.docker:
  image: alpine:latest
  services:
    - docker:${DOCKER_VERSION}-dind
  variables:
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_VERIFY: '1'
    DOCKER_TLS_CERTDIR: '/certs'
    DOCKER_CERT_PATH: '/certs/client'
    DOCKER_DRIVER: overlay2
    DOCKER_VERSION: '20.10.16'
    # assumes the Dagger Cloud token is
    # in a masked/protected variable named DAGGER_CLOUD_TOKEN
    # set via the GitLab UI
    DAGGER_CLOUD_TOKEN: $DAGGER_CLOUD_TOKEN
    
.dagger:
  extends: [.docker]
  before_script:
    - apk add docker-cli curl
    - curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sh
build:
  extends: [.dagger]
  script:
     - dagger install github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0
     - dagger -m github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0 call hello
#

I don't know how I can fix this.

#

And if I set this:
_EXPERIMENTAL_DAGGER_RUNNER_HOST: tcp://docker:2376 this let to connect ERROR: new client: context deadline exceeded

round marten
#

Oh, I see you do. Can you check really quick if commenting that helps to temporarily resolve the issue?

flat surge
#

Gives me the same error:

1: connect ERROR: new client: failed to run container: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
: exit status 125
round marten
flat surge
#

I will try it when my kids are sleeping

round marten
#

Wait, sorry I got confused

#

I have a gitlab repo where this works. Gimme a sec

round marten
#

Can we try something @flat surge. could you set DOCKER_HOST right before calling dagger call?

#

i.e: DOCKER_HOST=tcp://docker:2376 dagger call....

flat surge
#

Failed!.

#

The same gitlab.yml file is not working.

round marten
flat surge
#

Nope absolutely not.

#

This is now my file:

.docker:
  image: python:3.11-alpine
  services:
    - docker:${DOCKER_VERSION}-dind
  variables:
    DOCKER_HOST: tcp://docker:2376
    DOCKER_TLS_VERIFY: '1'
    DOCKER_TLS_CERTDIR: '/certs'
    DOCKER_CERT_PATH: '/certs/client'
    DOCKER_DRIVER: overlay2
    DOCKER_VERSION: '20.10.16'
    # assumes the Dagger Cloud token is
    # in a masked/protected variable named DAGGER_CLOUD_TOKEN
    # set via the GitLab UI
    #DAGGER_CLOUD_TOKEN: $DAGGER_CLOUD_TOKEN
    #_EXPERIMENTAL_DAGGER_RUNNER_HOST: tcp://docker:2376
.dagger:
  extends: [.docker]
  before_script:
    - apk add docker-cli curl
    #- curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=/usr/local/bin sh
    - cd /usr/local && { curl -L https://dl.dagger.io/dagger/install.sh | sh; cd -; }
build:
  extends: [.dagger]
  script:
     #- dagger install github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0
     - dagger -m github.com/shykes/daggerverse/hello@3338120927f8e291c4780de691ef63a7c9d825c0 call hello
#

And the result: https://gitlab.com/doe0003p/test-dagger/-/jobs/6397380006

1: [7.52s] registry.dagger.io/engine:v0.10.2
1: pulling registry.dagger.io/engine:v0.10.2 [7.24s]
1: starting engine 
1: starting engine [0.02s]
1: connect ERROR: new client: failed to run container: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
See 'docker run --help'.
: exit status 125
Error: new client: failed to run container: docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?.
#

@round marten Now it is running!

#

And that is really weird

round marten
#

:Wat:

#

Lol

flat surge
#

I deleted the environment Variable in the CI settings...

#

Here

#

If I set the variable here then it is failing again

round marten
#

What variable are you setting there?

flat surge
#

It was the DAGGER_CLOUD_TOKEN

round marten
#

Ok, that's very strange. The same thing happened to another user. I'll investigate tomorrow ๐Ÿ™Œ

flat surge
#

Thank you for your support.

flat surge
#

Hey @round marten,
any news on that? My pipeline is running now without the Dagger Cloud... ๐Ÿ˜ญ

jagged pumice
#

I have this exact same issue. If I set the DAGGER_CLOUD_TOKEN you get the Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? error.

If you set the _EXPERIMENTAL_DAGGER_RUNNER_HOST environment variable, the GitLab job just hangs until it times out.

#

It will be interesting to see if this error goes away by setting up a self-hosted runner (which isn't ideal, as it adds a lot of extra setup for a user)

round marten
#

Hey! Sorry I couldn't get back to this. I'm on vacation until Apr 7th. cc @thin stump might be able to take a look before I get back ๐Ÿ™

sudden hemlock
#

We were running into the same thing originally.
I'm not sure where we got this value from, but we have

variables:
    _EXPERIMENTAL_DAGGER_RUNNER_HOST: 'unix:///var/run/buildkit/buildkitd.sock'

and our traces are showing up in cloud

jagged pumice
jagged pumice
#

Are you using a custom runner?

sudden hemlock
#

Ya, we are using a custom runner,, which is probably why that worked for me

thin stump
urban oxide
# jagged pumice I have this exact same issue. If I set the `DAGGER_CLOUD_TOKEN` you get the `Can...

I ran into the same issue just trying to connect to a DOCKER_HOST, its very strange to me that DAGGER_CLOUD_TOKEN has anything to do with this

I filed an issue here: https://github.com/dagger/dagger/issues/6989

GitHub

What is the issue? I am running docker on a remote VM and connecting to it using the DOCKER_HOST env var. I can run docker commands without any issues on the remote host and when I try to call a da...

jagged pumice
thin stump
thin stump
#

@jagged pumice @flat surge are you able to try again with v0.11.0 just released?

flat surge
flat surge
#

@thin stump what was the problem?

thin stump
jagged pumice
#

@thin stump I can confirm that this fix has prevented the GitLab Shared Runner from reporting the connection error, and the pipeline has succeeded. However, I do not see anything in Dagger Cloud regarding the run on gitlab.com.

If I deliberately type in an incorrect DAGGER_CLOUD_TOKEN, I get the following errors, which does show me that my pipeline is talking to it:

Connected to engine 6fc07f48d450 (version v0.11.0)
05:27:06 ERR OpenTelemetry error error="traces export: failed to send to https://api.dagger.cloud/v1/traces: 401 Unauthorized"
05:27:06 ERR OpenTelemetry error error="traces export: failed to send to https://api.dagger.cloud/v1/traces: 401 Unauthorized"
05:27:06 ERR OpenTelemetry error error="failed to send to https://api.dagger.cloud/v1/logs: 401 Unauthorized"
05:27:06 ERR OpenTelemetry error error="failed to send to https://api.dagger.cloud/v1/logs: 401 Unauthorized"
flat surge
#

@thin stump I can also confirm that the fix is working. But the Dagger Cloud has some problems.
As @jagged pumice already mentioned I do not see anything in Dagger Cloud regarding the last run. Here I only see the run before 2 days.
Last if under All Changes when I click on the first entry (also 2 Days before) I get another error.

Finally what I want to mention is, that it feels pretty slow.

Connected to engine 94fbf7f92735 (version v0.11.0)
โœ” connect 21.0s
โœ” initialize 1m37.9s
โœ” Hello.hello: String! 0.5s
hello, world! 
thin stump
#

Hrm ok that's not great. @glossy sparrow do you know of that's still related to your fix or something different?

gloomy temple
#

I stopped seeing pipeline executions at /runs as well, but they're available at /traces

sudden hemlock
#

Where it shows up depends on the engine version.

>= 0.11.0 - /traces
<  0.11.0 - /runs
jagged pumice
#

@thin stump I can confirm that I see my traces within Dagger Cloud (from GitLab). I am using the new v2 (beta) version of the UI daggerfire