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(daemon): introduce reboot cleanup function #496

Closed
wants to merge 4 commits into from

Conversation

anpep
Copy link
Collaborator

@anpep anpep commented Sep 3, 2024

No description provided.

This reboot mode ensures that the machine is not restarted during
daemon.Stop() when a restart has been requested. Instead, it signals the
daemon.Stop() caller that further actions to ensure a restart are
required through a new exported error daemon.ErrRestartExternal.

This is required in scenarios where further actions are required before
the machine can be safely rebooted, such as syncing and unmounting
filesystems.
@anpep anpep requested a review from flotter September 3, 2024 15:05
@dimaqq dimaqq requested a review from benhoyt September 4, 2024 07:00
@flotter
Copy link
Contributor

flotter commented Sep 4, 2024

This PR adds another low level restart handler without changing the internal restart logic (i.e. restart manager) of the Daemon.

In a previous change, we (with the approval of CTO) added the syscall reboot handler. However, further work on a derivative system is proving that reboot request invocation inside the daemon is too limiting for our use-case. It either requires system knowledge passed into the daemon for cleanup, or the daemon can stay mostly system agnostic, but request cleanup + reboot to be dealt with by the caller.

1. Process entry point
2. Process system bootstrap
3. Daemon/Overlord start
:
4. Daemon/Overlord stop
5. Process system un-bootstrap (sync / umount / etc...)
6. Issue reboot (if requested)

Since the default reboot handler has to be explicitly changed, this has no impact on existing use cases.

Comment on lines 782 to 784
if rebootDelay > 0 {
time.Sleep(rebootDelay)
}
Copy link

Choose a reason for hiding this comment

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

doing this sleep inside HandleRestart seems wrong, you might have to distinguish the calls from HandleRestart vs doReboot now

@flotter
Copy link
Contributor

flotter commented Sep 9, 2024

@anpep

Regarding the timeout comment - inside HandleRestart there is a "backup" reboot scheduled for in-case the daemon teardown gets stuck. So as per Samuele's comment, that would not make sense to also defer to an external reboot. Let's brainstorm this through again.

Ben was asking if we should not just bypass the daemon here (which is what we have done). So I think we just revisit this to make sure out approach makes sense.

@anpep anpep changed the title feat(daemon): introduce "external" reboot mode feat(daemon): introduce reboot cleanup function Sep 11, 2024
@anpep
Copy link
Collaborator Author

anpep commented Oct 1, 2024

Closing for now, since it clearly needs more thought than I put into it initially. Let's work on this during the next cycle! Thanks for your feedback

@anpep anpep closed this Oct 1, 2024
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