systemd icon indicating copy to clipboard operation
systemd copied to clipboard

logind: implement maintenance window

Open lnussel opened this issue 3 years ago • 11 comments

Update frameworks that work automatically in the background occasionally need to schedule reboots. Systemd-logind already provides a nice mechanism to schedule shutdowns, send notfications and block logins short before the time. Systemd has a framework for calendar events, so we may conveniently use logind to define a maintenance window for reboots.

The existing ScheduleShutdown DBus method in logind expects a usec_t with an absolute time. So it would be possible to use 0 as magic value telling logind to take the time from the maintenance window if set. That would be really easy for programs to pass.

I'd like to have this working for the shutdown command too though so e.g "shutdown -r" would use the maintenance window automatically instead of the one minute default. Unfortunately internally systemctl treats 0 as no scheduled shutdown, so we have to use USEC_INFINITY instead.

lnussel avatar Oct 18 '22 09:10 lnussel

hmm, i don't grok the usecase for this? can you elaborate how an OS is supposed to use this? i guess I am missing the context here?

poettering avatar Oct 20 '22 17:10 poettering

This is basically porting the only relevant remaining feature of https://github.com/SUSE/rebootmgr to logind. The use case is to allow to define a specific time when a machine should reboot in case updates were staged. So the program installing the updates would call something like busctl call org.freedesktop.login1 /org/freedesktop/login1 org.freedesktop.login1.Manager ScheduleShutdown st reboot 0 and depending on setting would either reboot right away or at the defined maintenance window.

lnussel avatar Oct 20 '22 17:10 lnussel

Thanks for your review! I've adjusted the code as you suggested

lnussel avatar Dec 20 '22 12:12 lnussel

[!IMPORTANT] An -rc1 tag has been created and a release is being prepared, so please note that PRs introducing new features and APIs will be held back until the new version has been released.

github-actions[bot] avatar Nov 14 '23 15:11 github-actions[bot]

updated according to review. Agreeing on the actual naming is still open

lnussel avatar Nov 14 '23 15:11 lnussel

Please rebase.

yuwata avatar Jan 11 '24 05:01 yuwata

rebased

lnussel avatar Jan 17 '24 13:01 lnussel

finally got back to this. pr updated

lnussel avatar Mar 18 '24 16:03 lnussel

updated

lnussel avatar Apr 16 '24 14:04 lnussel

Looks great, just some naming stuff.

Also please rebase.

poettering avatar Apr 19 '24 16:04 poettering

fixed and rebased

lnussel avatar May 06 '24 16:05 lnussel