Skip to content

Conversation

savil
Copy link
Collaborator

@savil savil commented Jan 31, 2023

Summary

Updating:

  1. Event name to be of the form: [devbox] Shell event: interactive which is consistent with the command event names.
  2. Changing is_cloud to shell_access with values local | ssh | browser

How was it tested?

  • Need to test
  1. apply development keys for segment and sentry
  2. local: run local devbox shell and verify event logged in segment dashboard.
  3. ssh: deploy custom VM with custom devbox binary. verify event logged in segment dashboard.
  4. browser: Follow devbox-cloud README for http-gateway, but how do I test the custom devbox binary?

Copy link
Collaborator Author

savil commented Jan 31, 2023

Current dependencies on/for this PR:

This comment was auto-generated by Graphite.

@savil savil requested review from loreto and LucilleH January 31, 2023 22:35
AnonymousId: evt.AnonymousID,
Event: evt.eventName,
// Event name. We trim the prefix from shell-interactive/shell-ready to avoid redundancy.
Event: fmt.Sprintf("[%s] Shell Event: %s", evt.AppName, strings.TrimPrefix(eventName, "shell-")),
Copy link
Contributor

Choose a reason for hiding this comment

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

Are you sure this is what we want?

Wouldn't this add "Shell Event" to all events including the "Command" events that already exist?

I would have thought instead that you need to change the string wherever the shell-interactive event is triggered.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

no, those command events are still logged in midcobra/telemetry.go.
I have a cleanup I want to do to unify these further, but have held back since its a bit involved.

}

func shellAccess() shellAccessKind {
if os.Getenv("START_WEB_TERMINAL") == "1" {
Copy link
Contributor

Choose a reason for hiding this comment

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

OK, but ... Could you add a TODO/NOTE of some kind? At some point we'll have VMs with Gotty started that can be accessed via ssh or web, and this would treat them all as web. Really what we care about is the connection, that is running the command, not whether the VM has Gotty running or not.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

sure I can add a comment...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If you look at how START_WEB_TERMINAL works, its purpose is to ensure that we start the VM for browser shells. Whenever that logic changes, we'll need to update this as well.

@LucilleH suggested using this. Is there another more persistent way to detect that the shell is running as a browser shell?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the right behavior for now – I'm just saying we'll need to improve it and I like adding a TODO so it doesn't slip our minds.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The other approach is to rely on an SSH env var like SSH_USER_PUBLIC_KEY so:

// Check if in cloud
if os.Getenv("DEVBOX_REGION") != "" {
   if os.Getenv("SSH_USER_PUBLIC_KEY") != "" {
       return ssh
   } else {
       return browser
    }
}
return local

(need to test this)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I can use SSH_TTY

I dumped env for both ssh and browser shells to compare:

❯ cat web_env.txt | grep SSH
SSH_HOST_KEY=
DEFAULT_SSH_USER=devbox
SSH_USER=savil
SSH_USER_PUBLIC_KEY=
SSH_LISTEN_IPV4=0.0.0.0
SSH_LISTEN_IPV6=::
SSH_PORT=2222

❯ cat ssh_env.txt | grep SSH
SSH_CONNECTION=fdaa:0:a780:a7b:b2e2:41a9:b82f:2 58826 fdaa:0:a780:a7b:a1:ef3c:55b5:2 2222
SSH_CLIENT=fdaa:0:a780:a7b:b2e2:41a9:b82f:2 58826 2222
SSH_TTY=/dev/pts/0

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think for now this is fine to use START_WEB_TERMINAL 👍

Copy link
Contributor

@loreto loreto left a comment

Choose a reason for hiding this comment

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

LGTM

}

func shellAccess() shellAccessKind {
if os.Getenv("START_WEB_TERMINAL") == "1" {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is the right behavior for now – I'm just saying we'll need to improve it and I like adding a TODO so it doesn't slip our minds.

@savil savil force-pushed the savil/shell-tti-events branch from 11c4322 to 0af9aac Compare February 2, 2023 17:10
}

func shellAccess() shellAccessKind {
if os.Getenv("START_WEB_TERMINAL") == "1" {
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think for now this is fine to use START_WEB_TERMINAL 👍

// Check if running in devbox cloud
if os.Getenv("DEVBOX_REGION") != "" {
// Check if running via ssh tty (i.e. ssh shell)
if os.Getenv("SSH_TTY") != "" {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@loreto I think this approach is closer to what you wanted where we test for ssh versus browser based on access methodology.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good! Just make sure you test it :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I verified that SSH_TTY isn't present in browser shell:
#562 (comment)

@savil savil requested review from loreto and LucilleH February 2, 2023 20:25
@savil savil merged commit e1c1281 into main Feb 2, 2023
@savil savil deleted the savil/shell-tti-events branch February 2, 2023 21:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants