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

halt/stop command #298

Closed
tomjn opened this issue Nov 4, 2022 · 8 comments
Closed

halt/stop command #298

tomjn opened this issue Nov 4, 2022 · 8 comments

Comments

@tomjn
Copy link

tomjn commented Nov 4, 2022

Currently you can execute tart run however there is no way to stop this VM via a command either in the current shell or in another shell on the same system. It's also unclear how you would track the current status of the VM wether it was running or idle.

So, in addition to tart run, it would be nice to have a tart stop similar to vagrant halt. This would send a shutdown signal to the VM requesting it powerdown/exit gracefully. Ideally an additional parameter could be provided for a more forceful/bruteforce termination of the VM process

@tomjn
Copy link
Author

tomjn commented Nov 4, 2022

Noting that this could be implemented via #304 and something similar to tart ssh --command "sudo shutdown now"

@fkorotkov
Copy link
Contributor

For the CLI use case Tart was designed to not have a daemon running somewhere. This way consumers are responsible for killing tart process which will gracefully shutdown the VM. Hopefully vagrant can track own a process between vagrant up and vagrant halt?

@tomjn
Copy link
Author

tomjn commented Nov 6, 2022

hmmm it's not necessarily that a tart service or daemon needs to sit and actively monitor running VMs, though that is one way of doing it. Rather that vagrant itself is not a long running task. If Tart doesn't have some notes somewhere saying VM 1 is turned on with this PID then that means that running a command such as tart stop ubuntu to trigger the process exit will be difficult and there'll need to be some logic to do all of the housekeeping locally.

The downside of doing the housekeeping locally is that you then have to double check Tart exited gracefully and that the PID didn't get reused for something else.

@tomjn
Copy link
Author

tomjn commented Nov 6, 2022

Confirmed that you can SSH into a tart Linux VM and run sudo shutdown now to halt the machine.

Tart will show:

❯ tart run ubuntu
guest has stopped the virtual machine

It does require passwords entering but that's a configuration issue to add passwordless sudo.

@tomjn
Copy link
Author

tomjn commented Nov 6, 2022

The remaining problem is that it's not possible to do this simple set of commands if a vagrant provider was built:

# turn it on:
vagrant up <-- this command would never exit
# turn it off:
vagrant halt

@ringods
Copy link

ringods commented Nov 6, 2022

@tomjn something which came to mind: could the vagrant tart plugin spawn a child process when running vagrant up, so you decouple core Vagrant from the Tart specific handling? Core vagrant could then return as usual for vagrant up. At vagrant halt, the tart plugin could check for its own child process and signal termination.

@tomjn
Copy link
Author

tomjn commented Nov 8, 2022

@ringods theoretically, but that then leaves 2 new problems:

  • how do we tell the difference between a VM that is running, and a VM that is being created? E.g. if Tart hasn't finished starting up the VM yet
  • what's the difference between a VM that shutdown, and a VM that failed due to an error?

@edigaryev
Copy link
Collaborator

Closing because this has been resolved by #316.

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

No branches or pull requests

4 participants