这是indexloc提供的服务,不要输入任何密码
Skip to content

Conversation

@torarnv
Copy link
Contributor

@torarnv torarnv commented Jun 13, 2024

For macOS this brings up a dialog, asking the user if they are sure they want to shut down, which makes this less useful for automated graceful shutdowns, but it may behave better on Linux, and there might be ways to instruct macOS to not ask the user, so it's still a nice feature, and aligns with the SIGUSR1 for suspend, and SIGINT for non-graceful shutdown.

@edigaryev
Copy link
Collaborator

Would you mind elaborating a bit on the concrete use-case you're attempting to cover with this?

I have a rough guess from cirruslabs/packer-plugin-tart#153, but it still would be nice to have an exact reason for the history purposes.

@torarnv
Copy link
Contributor Author

torarnv commented Jun 14, 2024

Would you mind elaborating a bit on the concrete use-case you're attempting to cover with this?

I have a rough guess from cirruslabs/packer-plugin-tart#153, but it still would be nice to have an exact reason for the history purposes.

Sure 🙂 The use-case originated from cirruslabs/packer-plugin-tart#153 as you mention.

When automating Tart (packer plugin, or other CI integrations) you generally want to stop the VM in as clean of a fashion as possible. The packer plugin does this via shutdown -h now over SSH, which relies on there being a SSH communicator, and strictly speaking assumes that the guest OS supports that command.

To compliment that, as a last resort, if all else fails, the VM can be stopped without involving the guest via https://developer.apple.com/documentation/virtualization/vzvirtualmachine/3763076-stop, using SIGINT.

This PR adds the ability for automation to ask the VM guest to shut down, via https://developer.apple.com/documentation/virtualization/vzvirtualmachine/3656700-requeststop, which allows a more graceful stop flow. E.g. the automation would first ask the guest for a graceful stop, and if not stopped within 1 minute would then request a hard stop (as implemented in cirruslabs/packer-plugin-tart#153).

It also compliments the suspend, available via SIGUSR1.

In practice this feature is of limited usefulness for macOS specifically, due to the confirmation dialog macOS throws up:

Screenshot 2024-06-13 at 13 30 45

But other guest OS'es (Linux) may not have that issue, so exposing it as a general feature of Tart seems reasonable.

@edigaryev edigaryev self-requested a review June 14, 2024 17:33
@edigaryev
Copy link
Collaborator

For macOS this brings up a dialog, asking the user if they are sure
they want to shut down, which makes this less useful for automated
graceful shutdowns, but it may behave better on Linux, and there
might be ways to instruct macOS to not ask the user, so it's still
a nice feature, and aligns with the SIGUSR1 for suspend, and SIGINT
for non-graceful shutdown.
@torarnv torarnv force-pushed the add-graceful-shutdown-signal branch from f792ccf to 55aa25f Compare June 14, 2024 17:44
@torarnv
Copy link
Contributor Author

torarnv commented Jun 14, 2024

Thanks, fixed nit :)

@fkorotkov fkorotkov merged commit bf5081b into cirruslabs:main Jun 17, 2024
@torarnv torarnv deleted the add-graceful-shutdown-signal branch July 12, 2024 17:51
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.

3 participants