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

local cli: better logging for ws stop #19031

Merged
merged 4 commits into from
Nov 8, 2023
Merged

local cli: better logging for ws stop #19031

merged 4 commits into from
Nov 8, 2023

Conversation

filiptronicek
Copy link
Member

@filiptronicek filiptronicek commented Nov 7, 2023

Description

Summary generated by Copilot

🤖 Generated by Copilot at 2662c48

Refactored the workspace-stop command in the local app to improve logging and loop logic. Made the output more concise and user-friendly.

Related Issue(s)

Fixes EXP-883

How to test

In /workspace/gitpod/components/local-app/main/gitpod-cli,

go run . login --token <pat>
go run . ws create https://github.com/gitpod-io/gitpod/pull/18878
go run . ws stop <ws-id>

Documentation

Preview status

gitpod:summary

Build Options

Build
  • /werft with-werft
    Run the build with werft instead of GHA
  • leeway-no-cache
  • /werft no-test
    Run Leeway with --dont-test
Publish
  • /werft publish-to-npm
  • /werft publish-to-jb-marketplace
Installer
  • analytics=segment
  • with-dedicated-emulation
  • workspace-feature-flags
    Add desired feature flags to the end of the line above, space separated
Preview Environment / Integration Tests
  • /werft with-local-preview
    If enabled this will build install/preview
  • /werft with-preview
  • /werft with-large-vm
  • /werft with-gce-vm
    If enabled this will create the environment on GCE infra
  • with-integration-tests=all
    Valid options are all, workspace, webapp, ide, jetbrains, vscode, ssh. If enabled, with-preview and with-large-vm will be enabled.
  • with-monitoring

/hold

if HasInstanceStatus(wsInfo.Msg.Result) {
currentStatus = prettyprint.FormatWorkspacePhase(wsInfo.Msg.Result.Status.Instance.Status.Phase)
Copy link
Member Author

Choose a reason for hiding this comment

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

This actually made it so that the status never got updates (should be ws instead of wsInfo). Here we fix it as well

@@ -34,54 +34,60 @@ var workspaceStopCommand = &cobra.Command{
return err
}

slog.Info("stopping workspace...")
slog.Debug("stopping workspace...")
Copy link
Member Author

Choose a reason for hiding this comment

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

By default, we only output the waiting for workspace to stop... which can be found below. We essentially had 2 very similar messages, which are more useful for debugging than actually using the CLI.

@mustard-mh
Copy link
Contributor

mustard-mh commented Nov 7, 2023

✅ Tried with a create phase workspace (see third stop)
❌ Failed if try stop with a stopped workspace (hang)

image

Copy link
Contributor

@mustard-mh mustard-mh left a comment

Choose a reason for hiding this comment

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

Approve to unblock you (I'm going to sleep). There's a failed test case #19031 (comment)

if stopDontWait {
slog.Info("workspace stopping")
return nil
}

stream, err := gitpod.Workspaces.StreamWorkspaceStatus(ctx, connect.NewRequest(&v1.StreamWorkspaceStatusRequest{WorkspaceId: workspaceID}))

if err != nil {
return err
}
Copy link
Contributor

@mustard-mh mustard-mh Nov 7, 2023

Choose a reason for hiding this comment

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

In Golang we used to defer close / release something once it was created successfully (maybe there will have some special cases but it's a good habit to do so)

@filiptronicek
Copy link
Member Author

@mustard-mh as there's time enough to ship this, feel free to leave any more comments, I'd love to address them in the morning. We can merge later tomorrow.

Thanks for the feedback so far

@mustard-mh
Copy link
Contributor

Let's ship it and do further improvement if needed

@roboquat roboquat merged commit 9f692bb into main Nov 8, 2023
15 checks passed
@roboquat roboquat deleted the ft/EXP-883 branch November 8, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants