Skip to content

bug(engine): provisioning of dagger-engine not occuring when container is stopped #3793

Closed

Description

@grouville

Dagger fails to start running the dagger-engine- if the container (with the same name) already exists and is stopped.

Prerequisites
Make sure that no dagger engine is running (docker ps -a). Then:

> cd sdk/go
> go test  -count=1 -race -run=TestImageProvision -v ./...
=== RUN   TestImageProvision
--- PASS: TestImageProvision (17.80s)
PASS
ok      dagger.io/dagger        18.037s
?       dagger.io/dagger/internal/engineconn    [no test files]
?       dagger.io/dagger/internal/engineconn/dockerprovision    [no test files]
?       dagger.io/dagger/internal/engineconn/http       [no test files]
?       dagger.io/dagger/internal/engineconn/unix       [no test files]
testing: warning: no tests to run
PASS
ok      dagger.io/dagger/internal/querybuilder  0.172s [no tests to run]

Now, stop the dagger-engine- container, and re-run the tests:

> docker stop $(docker ps -a | grep dagger-engine- | cut -d " " -f 1)
> go test  -count=1 -race -run=TestImageProvision -v ./...
=== RUN   TestImageProvision
    provision_test.go:72: 
                Error Trace:    /Users/home/Documents/dagger-worktree/macos-runner/sdk/go/provision_test.go:72
                Error:          Received unexpected error:
                                EOF
                                Please visit https://dagger.io/help#go for troubleshooting guidance.
                Test:           TestImageProvision
--- FAIL: TestImageProvision (22.41s)
FAIL
FAIL    dagger.io/dagger        22.792s
?       dagger.io/dagger/internal/engineconn    [no test files]
?       dagger.io/dagger/internal/engineconn/dockerprovision    [no test files]
?       dagger.io/dagger/internal/engineconn/http       [no test files]
?       dagger.io/dagger/internal/engineconn/unix       [no test files]
testing: warning: no tests to run
PASS
ok      dagger.io/dagger/internal/querybuilder  0.260s [no tests to run]
FAIL

Paired with @marcosnils 🙏

cc @sipsma

Activity

  1. sipsma commented on Nov 11, 2022

    @sipsma
    Contributor

    Was this encountered only by manually stopping the container or did the container stop for some other reason?

    We set --restart always so if it's not manually stopped then it should restart on its own I think.

    If the container was manually stopped by the user I'm not sure whether we actually should have our code restart it. All the setup code is automated, but if the user specifically goes out of their way to stop the container maybe it makes more sense to honor that and just let them manually start it again?

    On the other hand, maybe that breaks the "magic" of automated provisioning. If we want to force restart the container then we should just change the provisioning code in internal/engine/docker.go to do a docker create followed by docker start rather than one docker run. That should give us idempotent behavior I think.

    I'd probably air on the side of force restarting it for now since it results in the overall simplest behavior, but open to other opinions.

  2. marcosnils commented on Nov 11, 2022

    @marcosnils
    Contributor

    Was this encountered only by manually stopping the container or did the container stop for some other reason?

    Not sure it was accidentally stopped, but for some reason the engine process Exited and it was in "stopped" status.

    I guess the main issue was that dagger.Connect was failing because of this and we didn't get a proper error message about it in the test.

  3. sipsma commented on Nov 11, 2022

    @sipsma
    Contributor

    I guess the main issue was that dagger.Connect was failing because of this and we didn't get a proper error message about it in the test.

    Yeah EOF is not very descriptive. Do you get a descriptive error if you configure log output in the client made by the test? I'm on mobile so hard to double check the code to see if that's already there atm

  4. grouville commented on Nov 11, 2022

    @grouville
    MemberAuthor

    Tried it, nope

  5. grouville commented on Dec 21, 2022

    @grouville
    MemberAuthor

    Following @sipsma's comment, it is safe to close this issue.

    If the container was manually stopped by the user I'm not sure whether we actually should have our code restart it. All the setup code is automated, but if the user specifically goes out of their way to stop the container maybe it makes more sense to honor that and just let them manually start it again?

  6. marcosnils commented on Dec 21, 2022

    @marcosnils
    Contributor

    @grouville shall we create a new issue to improve error handling on this case?

  7. grouville commented on Dec 21, 2022

    @grouville
    MemberAuthor

    @grouville shall we create a new issue to improve error handling on this case?

    Great idea !

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions