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: add support for exiting ssh session #3331

Merged
merged 1 commit into from
Mar 12, 2025

Conversation

unsuman
Copy link
Contributor

@unsuman unsuman commented Mar 10, 2025

This PR fixes #3125 by adding a boolean flag, --exit-session, to the limactl shell command, enabling users to exit the current SSH session. Additionally, it introduces an alias ssh for the shell command.

@afbjorklund
Copy link
Member

That's still two different things in one PR, keeping them separate makes for easier review

@@ -49,6 +51,7 @@ func newShellCommand() *cobra.Command {

shellCmd.Flags().String("shell", "", "shell interpreter, e.g. /bin/bash")
shellCmd.Flags().String("workdir", "", "working directory")
shellCmd.Flags().BoolP("exit-session", "e", false, "exit a ssh session for the instance")
Copy link
Member

Choose a reason for hiding this comment

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

I'd prefer to reserve e for now. (Potentially for something similar to ssh -e)
Can be revisited later.

@@ -49,6 +51,7 @@ func newShellCommand() *cobra.Command {

shellCmd.Flags().String("shell", "", "shell interpreter, e.g. /bin/bash")
shellCmd.Flags().String("workdir", "", "working directory")
shellCmd.Flags().BoolP("exit-session", "e", false, "exit a ssh session for the instance")
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
shellCmd.Flags().BoolP("exit-session", "e", false, "exit a ssh session for the instance")
shellCmd.Flags().Bool("exit-session", false, "exit a ssh session before running the command, for <REASON>")

Copy link
Member

Choose a reason for hiding this comment

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

Bikeshedding: something like --reestablish-session might be less confusing?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@AkihiroSuda I want to know what we are trying to achieve here. Is it only a shell termination or a termination + re-establish?

Bikeshedding: something like --reestablish-session might be less confusing?

I guess this will be a little long for a user to type, --restart if you will?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe --restart-ssh ?

--restart sounds like restarting the VM. --exit sounds like exiting SSH without executing a command.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

--restart-ssh sounds great!

jandubois
jandubois previously approved these changes Mar 11, 2025
Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

Only concern is the option name; waiting for feedback from other @lima-vm/maintainers before merging.

@@ -49,6 +50,7 @@ func newShellCommand() *cobra.Command {

shellCmd.Flags().String("shell", "", "shell interpreter, e.g. /bin/bash")
shellCmd.Flags().String("workdir", "", "working directory")
shellCmd.Flags().Bool("restart-ssh", false, "restart the SSH connection")
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely bike-shedding now, but the --restart-ssh name somehow doesn't vibe with me. It feels more like an implementation detail than expressing what the user wants.

I think both --restart-session or even --reconnect would work better.

Another reason is that I think eventually we will use a different transport depending on the driver. E.g. with WSL2 it makes sense to execute commands via wsl -d $DISTRO instead of ssh. So using ssh in the option name would feel wrong in that situation.

@unsuman unsuman force-pushed the feat/exit-ssh-session branch from c9097fe to fc974a5 Compare March 12, 2025 10:51
Copy link
Member

@jandubois jandubois left a comment

Choose a reason for hiding this comment

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

Thanks, LGTM

Thanks for changing the settins name to --reconnect, which does work for me. However, I wanted to hear from other @lima-vm/maintainers about their opinion.

So I'm approving this PR, but leave it to the others to either merge, or continue to bike-shed it.

@AkihiroSuda AkihiroSuda added this to the v1.1.0 milestone Mar 12, 2025
Copy link
Member

@AkihiroSuda AkihiroSuda left a comment

Choose a reason for hiding this comment

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

Thanks, --reconnect seems good

@AkihiroSuda AkihiroSuda merged commit 7374528 into lima-vm:master Mar 12, 2025
31 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.

Command to exit the ssh session
4 participants