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

Software Updates: integrate new "reboot" configuration option from dnf-automatic #18593

Closed
ishimko opened this issue Apr 1, 2023 · 5 comments

Comments

@ishimko
Copy link

ishimko commented Apr 1, 2023

Page: Software Updates

Currently automatic reboot after installing updates is achieved by a custom script, which does check whether something was installed or not via searching for a =========== sequence:

// HACK: enable automatic reboots after updating; dnf-automatic does not leave a log file behind for
// deciding whether it actually installed anything, so resort to grepping the journal for the last run
// (https://bugzilla.redhat.com/show_bug.cgi?id=1491190)
script += "mkdir -p /etc/systemd/system/dnf-automatic-install.service.d; ";
script += "printf '[Service]\\nExecStartPost=/bin/sh -ec \"" +
"if systemctl status --no-pager --lines=100 dnf-automatic-install.service| grep -q ===========$$; then " +
"shutdown -r +5 rebooting after applying package updates; fi\"\\n' > " + rebootConf + "; ";
script += "systemctl daemon-reload; ";

The bug mentioned in a code comment mentions that a new option reboot was added to automatic.conf: rpm-software-management/dnf#1879, which can be used instead (when-changed flag gives this behavior).

@s57oyusu
Copy link
Contributor

s57oyusu commented Apr 4, 2023

Page: Software Updates

Currently automatic reboot after installing updates is achieved by a custom script, which does not check whether something was installed or not:

if (enabled) {
// HACK: enable automatic reboots after updating; dnf-automatic does not leave a log file behind for
// deciding whether it actually installed anything, so resort to grepping the journal for the last run
// (https://bugzilla.redhat.com/show_bug.cgi?id=1491190)
script += "mkdir -p /etc/systemd/system/dnf-automatic-install.service.d; ";

The bug mentioned in a code comment mentions that a new option reboot was added to automatic.conf: rpm-software-management/dnf#1879, which can be used instead to avoid reboots when nothing was installed (when-changed flag gives this behavior).

Hey @ishimko . I think before automatically rebooting there is a check in the second line of the following script using grep -q.

      script += "printf '[Service]\\nExecStartPost=/bin/sh -ec \"" +
                          "if systemctl status --no-pager --lines=100 dnf-automatic-install.service| grep -q ===========$$; then " +
                          "shutdown -r +5 rebooting after applying package updates; fi\"\\n' > " + rebootConf + "; ";

@ishimko
Copy link
Author

ishimko commented Apr 4, 2023

Hi @omarY23, apologize for my mistake, you're right. I was almost sure I experienced reboot without any updates being installed, but now I am checking logs and see that there were updates, so this ======= magic line was used like a marker.

However I still believe it could be beneficial to switch to the new documented option, even though current solution seems to provide the same behavior. For instance there could be a UI dropdown list which allows selecting from when-changed/when-needed/never as per new option in dnf-automatic.

I am good closing this issue as it is not accurate with it's current wording.

UDP: the title is accurate, but not description to be precise, I'll better update description so that maintainers could make a decision whether they want this "hack" to be fixed this way or not.

@s57oyusu
Copy link
Contributor

s57oyusu commented Apr 4, 2023

Hi @omarY23, apologize for my mistake, you're right. I was almost sure I experienced reboot without any updates being installed, but now I am checking logs and see that there were updates, so this ======= magic line was used like a marker.

However I still believe it could be beneficial to switch to the new documented option, even though current solution seems to provide the same behavior. For instance there could be a UI dropdown list which allows selecting from when-changed/when-needed/never as per new option in dnf-automatic.

I am good closing this issue as it is not accurate with it's current wording.

UDP: the title is accurate, but not description to be precise, I'll better update description so that maintainers could make a decision whether they want this "hack" to be fixed this way or not.

No worries @ishimko. By the way, the point you raised was right according to me. The auto rebooting could be enhanced using the new reboot option. I think @KKoukiou could tell you better if this is needed or not.

@jelly
Copy link
Member

jelly commented Sep 1, 2023

Hi @omarY23, apologize for my mistake, you're right. I was almost sure I experienced reboot without any updates being installed, but now I am checking logs and see that there were updates, so this ======= magic line was used like a marker.

However I still believe it could be beneficial to switch to the new documented option, even though current solution seems to provide the same behavior. For instance there could be a UI dropdown list which allows selecting from when-changed/when-needed/never as per new option in dnf-automatic.

Using the standard provided mechanism is much preferred, as this feature is relatively new we'd need to handle old and new dnf.

@martinpitt
Copy link
Member

This was done in PR #19648

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants