-
Notifications
You must be signed in to change notification settings - Fork 414
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
Add reboot
option to DNF Automatic
#1879
Add reboot
option to DNF Automatic
#1879
Conversation
Hey, I am looking at the PR and the first thing that comes up is the commit message.
|
Add ability in DNF Automatic to automatically trigger a reboot after an upgrade. The `reboot` option supports three settings: ``never`` does not reboot the system (current behavior). ``when-changed`` triggers a reboot after any upgrade. ``when-needed`` triggers a reboot only when rebooting is necessary to apply changes, such as when systemd or the kernel is upgraded. The `reboot_command` option allows customizing the command used to reboot (default is `shutdown -r`). = changelog = msg: Add `reboot` option to DNF Automatic type: enhancement resolves: https://bugzilla.redhat.com/show_bug.cgi?id=2124793
9be6472
to
cafcd57
Compare
Thanks, done. |
etc/dnf/automatic.conf
Outdated
reboot = never | ||
|
||
# The command that is run to trigger a system reboot. | ||
reboot_command = "shutdown -r" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was testing your code today, and I was thinking whether our ci is suitable or not for testing what you want. Probably, there is no simple way to trigger a reboot, but there are other options.
Since you set a custom command here, I would think of another way to test the reboot trigger.
Maybe, during behave tests, you could set an arbitrary command in etc/dnf/automatic.conf
. Let's say that instead of shutdown -r
you touch
some file, then you can check if the file exists and have the trigger tested. Unfortunately this is the only partial solution I came up with.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR: Cockpit's updates page delays the shutdown by a bit, so that logged in users get a warning and have some time to orderly stop their work. That's a good thing to do on servers IMHO.
That same thing also allows you to test this feature relatively painlessly: It's enough time to validate that a shutdown was scheduled and cancel it again (like in our tests). That avoids the costly (time) or impossible (Testing Farm/gating tests) actual reboot.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR: Cockpit's updates page delays the shutdown by a bit, so that logged in users get a warning and have some time to orderly stop their work. That's a good thing to do on servers IMHO
That's a good idea.
That same thing also allows you to test this feature relatively painlessly
That does not apply for dnf
, since we run our tests in containers. But you cannot really test if a system reboots universally. Say that a system does not have the shutdown
command, then the only thing you can test is to check if the hook triggers. It would be the user/sysadmin/distro responsibility to configure the conf file accordingly.
Said that, it's not a big deal imho since we are not testing the capability of shutdown -r
of rebooting the system.
It's enough time to validate that a shutdown was scheduled and cancel it again
I think this would be the solution in most cases.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FTR: Cockpit's updates page delays the shutdown by a bit, so that logged in users get a warning and have some time to orderly stop their work. That's a good thing to do on servers IMHO.
Thanks for the input, I've made the default reboot_command
add a 5-minute delay and wall message.
@inknos how does rpm-software-management/ci-dnf-stack#1210 look? I set the reboot_command
to echo a certain string, then check that stdout contains that string. Maybe touching a file is a more reliable way to make sure the command is actually run, but I think this should be sufficient.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the stoud approach, I will post some comments about the CI PR and then I believe this is good to go. Thank you
# List taken from DNF needs-restarting | ||
need_reboot = frozenset(('kernel', 'kernel-rt', 'glibc', | ||
'linux-firmware', 'systemd', 'dbus', | ||
'dbus-broker', 'dbus-daemon')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to share this set with needs-restarting
plugin somehow.
One option would be a new config option. In this case it should be implemented also for dnf5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm true, would doing this via a new config option require a change in libdnf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, if we agree that it is useful, it will be spread across libdnf, dnf, dnf-plugins-core, and dnf5 :)
But I'm not gonna block this PR because of that. It could be done in subsequent patches.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I think we can hold off for now and err on the side of minimal changes. Hopefully this list doesn't change too much over the years. But it would be good for it to be configurable by the user.
I think we are good to merge now. |
Add ability in DNF Automatic to automatically trigger a reboot after an upgrade. The
reboot
option supports three settings:never
does not reboot the system (current behavior).when-changed
triggers a reboot after any upgrade.when-needed
triggers a reboot only when rebooting is necessary to apply changes, such as when systemd or the kernel is upgraded.Then
when-needed
option followsdnf needs-restarting
's approach for determining whether a reboot is needed; we just look to see whether any "core" packages are involved in the transaction, e.g. the kernel, systemd, dbus, glibc.I'm still not sure the best way to write a test for this feature, maybe someone has suggestions.
See https://bugzilla.redhat.com/show_bug.cgi?id=2124793