Skip to content

Replace engine-session binary w/ cli session cmd. - #4145

Merged
sipsma merged 3 commits into
dagger:mainfrom
sipsma:cli-session
Dec 10, 2022
Merged

sipsma merged 3 commits into
dagger:mainfrom
sipsma:cli-session

Conversation

@sipsma

@sipsma sipsma commented Dec 9, 2022 •

Copy link
Copy Markdown
Contributor

Major changes:

  1. No more separate engine-session binary, now session is a hidden subcommand of the CLI
    • For now the CLI is thus included w/ the engine image, same as engine session before. See below for next steps
  2. SDKs read json encoded url+session token from stdout instead of just port. They are now compatible with dagger run usage.
  3. Dagger-in-dagger is hugely simplified, lots of deleted code. Updates were needed in order for some existing test cases to pass, which is why it's included in this PR.
    • When it's enabled, the shim just directly opens a new session and serves it over localhost, setting DAGGER_SESSION_* in the same way that dagger run does.
    • There's no longer any need for mounting in a bin or the buildkitd socket and no needed for any socket proxying of the session/buildkit api.

The next+final step in this effort is to have the SDKs download the CLI from S3 rather than grabbing it out of the engine image.

NOTE: there's a lot of awkward ugly code around first trying DAGGER_SESSION_URL, then _EXPERIMENTAL_DAGGER_CLI_BIN, then finally falling back to the previous code that used DAGGER_HOST.

  • This is only needed because we can't delete the DAGGER_HOST stuff until we make the change to download the bin from s3
  • Once that follow up is merged the ugly code can be cleaned up and a ton of the old provisioning code (and associated complication with registering different schemes) will all go away.

@sipsma

sipsma commented Dec 9, 2022 •

Copy link
Copy Markdown
Contributor Author

The tests pass consistently for me locally, not sure why they fail here consistently... Looking into it.

EDIT: it was an issue w/ dagger-in-dagger (which is still used via the extension tests we have). Didn't hit it locally because of caching. The fix to this ended up being pretty nice actually, simplified a lot, describe it in 3 under Major changes in the PR description.

This is partially needed just due to the updates around the new
_EXPERIMENTAL_* env vars interpreted by the SDKs. But it also ends up
being a pretty big simplification.

When dagger-in-dagger is enabled, the shim just opens a new session and
serves it over localhost, setting DAGGER_SESSION_* in the same way that
dagger run does.

There's no longer any need for mounting in a bin or the buildkitd socket
and no needed for any socket proxying of the session/buildkit api.

Signed-off-by: Erik Sipsma <[email protected]>
@sipsma
sipsma marked this pull request as ready for review December 10, 2022 02:00
Comment thread hack/dev
popd

export DAGGER_HOST=docker-container://test-dagger-engine
export _EXPERIMENTAL_DAGGER_CLI_BIN=$DAGGER_SRC_ROOT/bin/dagger

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is awesome

Comment thread hack/dev

export DAGGER_HOST=docker-container://test-dagger-engine
export _EXPERIMENTAL_DAGGER_CLI_BIN=$DAGGER_SRC_ROOT/bin/dagger
export _EXPERIMENTAL_DAGGER_RUNNER_HOST=docker-container://test-dagger-engine

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extremely small nit: any chance we can get rid of this, since now it's all encapsulated in the CLI and we control what it does

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I considered that briefly, it would require using -X to overwrite the binary's default runner host (but right now -X is only used to set the version stamp, so more refactoring would be needed). I guess I'm not sure that's worth it yet since it would be a lot of lines of code to replace just this one.

@sipsma
sipsma merged commit 8202b2e into dagger:main Dec 10, 2022
"""Error while provisioning the Dagger engine."""


@register_engine("http")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't get the chance to review. It's not necessary to register this. This line should be removed.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, sorry about that, this PR was mostly just an intermediate step before the last step in this effort which is to have the SDKs all download the binary from S3 instead of pulling them from the docker image. As part of that I am deleting and refactoring tons of code across the SDKs, so I wanted to get PR in first and then clean everything up in that next one. I'll clean this up there and wait for your approval on that one 🙏

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants