Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: improve engine session loading logging #5488

Merged
merged 13 commits into from
Jul 31, 2023

Conversation

TomChv
Copy link
Member

@TomChv TomChv commented Jul 19, 2023

Add few lines during engine loading to update user. This PR update Typescript and Go SDK.

Related to: #4820

Example on Typescript SDK

yarn start
yarn run v1.22.19
$ node --loader ts-node/esm ./index.mts
(node:97293) ExperimentalWarning: Custom ESM Loaders is an experimental feature and might change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Starting Dagger session...
Dagger session started! Establishing connection with the SDK...
Connection established with Dagger session version 0.6.3

Example on Go SDK

go run ./test.go                                                    
Starting Dagger session...
Dagger session started! Establishing connection with the SDK...
Connection established with Dagger session version 0.6.3!
3: resolve image config for docker.io/library/alpine:latest

@gerhard Should I add a change in the release note with this PR? I think it's a really small change but it can be useful!

Note: Originally, I tried to do something with a progress bar but it became really complex for just a logging issue, I went back to something simpler but still effective!

@helderco I saw you already did some work on logging, should I also add these print in the Python SDK?

EDIT: NEW FORMAT

Creating new Engine session... OK!
Establishing connection to Engine... OK!

And in case of CLI downloading:

CLI not found, downloading it... OK!
Creating new Engine session... OK!
Establishing connection to Engine... OK!

@TomChv TomChv requested review from vito, gerhard and helderco July 19, 2023 16:05
@TomChv TomChv self-assigned this Jul 19, 2023
@TomChv TomChv changed the title feat: improve engine session loading feat: improve engine session loading logging Jul 19, 2023
@TomChv TomChv force-pushed the feat/sdk-engine-load-logs branch from 2aa0828 to 8bd6ab7 Compare July 19, 2023 16:11
@gerhard
Copy link
Member

gerhard commented Jul 19, 2023

@TomChv: Should I add a change in the release note with this PR?

If it's a user-facing change, then yes. Remember to add it in as many places as needed (both sdk/go & sdk/nodejs in this case). FWIW: #5408

TIP: changie new --kind "Fixed" --body "Show when Engine is loading in the output" --custom "Author=TomChv" --custom "PR=5488"

@TomChv TomChv force-pushed the feat/sdk-engine-load-logs branch from 5500a01 to 5d9becb Compare July 20, 2023 16:45
@gerhard
Copy link
Member

gerhard commented Jul 20, 2023

Picking this one up now.

Copy link
Member

@gerhard gerhard left a comment

Choose a reason for hiding this comment

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

I pushed a wording change to the Node.js SDK. Does this read better to you @TomChv?

Before:

Starting Dagger session...
Dagger session started! Establishing connection with the SDK...
Connection established with Dagger session version 0.0.0

After:

Creating new Engine session... OK!
Establishing connection to Engine... OK!

I also removed the the SDK version from the output since it will be confusing if/when the Engine/CLI version differs from the SDK version.

WDYT?

@TomChv
Copy link
Member Author

TomChv commented Jul 21, 2023

@gerhard LGTM, let's merge it after I also update the Go SDK with the same changes

Copy link
Member

@gerhard gerhard left a comment

Choose a reason for hiding this comment

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

After the last few changes, this looks good to me! WDYT @TomChv?

I would be very keen to get @helderco & @vito's eyes on this. The changes in this PR feel just as much mine as they are yours @TomChv. As a result, I will abstain from approving.

Copy link
Contributor

@helderco helderco left a comment

Choose a reason for hiding this comment

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

You're missing the download step (i.e., when no CLI is found in the cache, it's downloaded).

sdk/go/.changes/unreleased/Fixed-20230720-184344.yaml Outdated Show resolved Hide resolved
sdk/go/internal/engineconn/session.go Outdated Show resolved Hide resolved
sdk/nodejs/provisioning/bin.ts Outdated Show resolved Hide resolved
@gerhard
Copy link
Member

gerhard commented Jul 25, 2023

Is this one @helderco linked to #3806 by any chance? What about #3838?

@helderco
Copy link
Contributor

It was #4186 as a follow up to #3806 but closed in favor of #4820.

@TomChv TomChv force-pushed the feat/sdk-engine-load-logs branch from 096c33b to 8f00d7f Compare July 26, 2023 11:06
@TomChv
Copy link
Member Author

TomChv commented Jul 26, 2023

@gerhard @helderco I have applied your comments! 🚀

@TomChv TomChv requested a review from helderco July 26, 2023 11:08
Copy link
Contributor

@helderco helderco left a comment

Choose a reason for hiding this comment

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

Almost there 🙂

sdk/go/.changes/unreleased/Fixed-20230720-184344.yaml Outdated Show resolved Hide resolved
sdk/go/internal/engineconn/cli.go Outdated Show resolved Hide resolved
@helderco
Copy link
Contributor

It's very noisy when running multiple connects (e.g., in tests):

go test
Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... Downloading CLI... OK!
Creating new Engine session... OK!
Establishing connection to Engine... OK!
OK!
Creating new Engine session... OK!
Establishing connection to Engine... Creating new Engine session... OK!
Establishing connection to Engine... OK!
OK!
Creating new Engine session... OK!
Establishing connection to Engine... OK!
Creating new Engine session... OK!
OK!
Establishing connection to Engine... Creating new Engine session... OK!
Establishing connection to Engine... OK!
OK!
OK!
Creating new Engine session... OK!
Establishing connection to Engine... Creating new Engine session... Creating new Engine session... OK!
Establishing connection to Engine... Creating new Engine session... OK!
Establishing connection to Engine... OK!
Establishing connection to Engine... OK!
OK!
OK!
OK!
OK!
OK!
OK!
OK!
OK!
OK!
PASS
ok  	dagger.io/dagger	46.922s

In this case, the OK!s don't match.

@helderco
Copy link
Contributor

helderco commented Jul 28, 2023

It even shows in dagger run because of tests using LogOutput:

Screenshot 2023-07-28 at 12 07 57

However, I'm using just go test here, not ./hack/make where the nested dev engine is. I expected the existing session to be detected.

EDIT: It's because of TestProvision.

@TomChv
Copy link
Member Author

TomChv commented Jul 28, 2023

This is why I wanted to add a special flag so we can explicitely trigger the display of the loading

@helderco
Copy link
Contributor

Copy link
Contributor

@helderco helderco left a comment

Choose a reason for hiding this comment

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

We can do follow ups to improve on this, but lgtm for now. Rather have the fixed test, but non blocking.

@helderco
Copy link
Contributor

One approach I took in Python was to only do this on TTY. The intent is to show that something's happening when it's run interactively, not when writing to a file for example.

I understand why you wanted the flag, but I'm more inclined for any smart detection we can make, up to a general escape hatch for the default of showing the output. Not a flag for explicitly enabling it. In Python there's an escape hatch, but not a specific setting for it either. And detecting for TTY probably avoids some of situations where you'd want to escape it anyway.

As for #5488 (comment), that test is testing concurrent provisioning for the automatic provisioning feature in the SDK, so it explicitly ignores an existing session. I say it's not a big deal in this case and we can remove LogOutput from the test. We'll be focusing more on the CLI experience going forward so hopefully less and less users will be running off the SDK directly in the future.

In the meantime this is the problematic situation that remains. It's if someone is doing multiple Connects when executing via the SDK, so that provisioning logging will be all over the place. I've seen it being done in a complex python SDK codebase, especially in a test suite that uses dagger, so I wanted to make sure I had that covered. Two things help there: 1) status update is replaced in line and disappears when run interactively; 2) No status updates are printed when running non-interactively (e.g., log_output to a file).

However, in this PR I think we can cross that bridge when we get there and improve then. This already feels like an improvement, and you can add the tty check as well.

Vasek - Tom C and others added 12 commits July 31, 2023 12:02
Add few lines during engine loading to update user.
This PR update Typescript and Go SDK.

Related to: dagger#4820

Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Remove the SDK version from the output since it will be confusing
if/when the Engine/CLI version differs from the SDK version.

Before:
    Starting Dagger session...
    Dagger session started! Establishing connection with the SDK...
    Connection established with Dagger session version 0.0.0

After:
    Creating new Engine session... OK!
    Establishing connection to Engine... OK!

Signed-off-by: Gerhard Lazu <gerhard@dagger.io>
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Signed-off-by: Gerhard Lazu <gerhard@dagger.io>
Signed-off-by: Gerhard Lazu <gerhard@dagger.io>
Without this, users will need to do an extra step to get this output.
The idea is that this should work better **out of the box**, without
adding an extra burden on users.

Signed-off-by: Gerhard Lazu <gerhard@dagger.io>
Remove `EngineLoading` output.
Add extra log when downloading CLI.

Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
@TomChv TomChv force-pushed the feat/sdk-engine-load-logs branch from 45741c7 to 0facd07 Compare July 31, 2023 11:02
Signed-off-by: Vasek - Tom C <tom@epitech.eu>
@TomChv TomChv merged commit c5aed99 into dagger:main Jul 31, 2023
21 checks passed
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.

None yet

4 participants