-
Notifications
You must be signed in to change notification settings - Fork 86
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
Implement dnf5 needs-restarting plugin #887
Implement dnf5 needs-restarting plugin #887
Conversation
Would it be possible the reverse the exit codes? Now the codes match to "does-not-need-restart" question. |
Hmm, yes using code 0 (truthy) to mean "no restart" does make scripts read a bit awkward, I see your point:
Similar tools like tracer, Debian's checkrestart, and I think of "no reboot needed" as the default, unsurprising, comfortable result and "reboot needed" as the less common result that needs to be handled. The exit codes make more sense from that perspective. |
Adjust list of core packages to include everything from https://access.redhat.com/solutions/27943
cd8fddd
to
0088b87
Compare
cd366af
to
29f83e5
Compare
The new behavior of `dnf5 needs-restarting --services` still lists systemd services that should be restarted following an upgrade, but instead of checking open files like dnf4 needs-restarting, it checks whether any dependency of the package that provides the service has been updated since the service started.
dnf4 needs-restarting's logic to get the boot time doesn't work when the RTC exists but gives unreliable information (e.g. it's not in UTC). When systemd is available, we should just ask systemd when the system booted. When systemd is not available, we are likely in a container, and stat /proc/1 will probably yield a correct answer.
29f83e5
to
167c0e9
Compare
Alright, I think this is ready for review now. |
0cd91ea
to
b11d6c9
Compare
LGTM, thanks for the cooperation! 🙂 One more thing: as already mentioned, the existing tests in the CI stack do not cover all functionalities provided by this new DNF5 version of the needs-restarting plugin, particularly regarding the reboot suggested packages. I believe the updateinfo metadata can be mocked for this purpose, allowing us to create testing data and write the necessary tests using the current state of the CI stack. Please create a follow-up issue in the CI stack to ensure we address this. |
Oh, I just realized that the existing tests aren't being executed for dnf5 at the moment. We should attempt to reuse at least some of them. |
Update the needs-restarting tests for DNF 5 and add a test for recommending a reboot when a package has an associated reboot_suggested advisory. Requires rpm-software-management/dnf5#887 For rpm-software-management/dnf5#743
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.
Just a couple minor typos, otherwise LGTM.
Also I believe the changes in rpm/nevra.hpp
are technically not longer needed but we can keep them if you think they might be useful in the future.
filter_reboot_suggested was binary searching the results of get_advisory_packages_sorted_by_name_arch_evr() assuming they were sorted according to cmp_naevr, however that function actually returns packages sorted by the libsolv ids of name, arch, and evr, not the string representations of name, arch, and evr like cmp_naevr does.
True, I think we might as well keep them. |
48a643f
to
4f459d8
Compare
I just noticed the |
DNF 4 needs-restarting -r has essentially the same behavior as DNF 5 needs-restarting with no flag, so the flag should be kept in as a no-op for backwards compatibility.
4f459d8
to
1c0e75f
Compare
Sigh... thank you. One more force push... |
Great and thank you for your patience with such an exhaustive review 🙂 I believe we can proceed with the merge now, as Ales mentioned only minor typos. |
419fed5
Update the needs-restarting tests for DNF 5 and add a test for recommending a reboot when a package has an associated reboot_suggested advisory. Requires rpm-software-management/dnf5#887 For rpm-software-management/dnf5#743
Update the needs-restarting tests for DNF 5 and add a test for recommending a reboot when a package has an associated reboot_suggested advisory. Requires rpm-software-management/dnf5#887 For rpm-software-management/dnf5#743
Update the needs-restarting tests for DNF 5 and add a test for recommending a reboot when a package has an associated reboot_suggested advisory. Requires rpm-software-management/dnf5#887 For rpm-software-management/dnf5#743
Update the needs-restarting tests for DNF 5 and add a test for recommending a reboot when a package has an associated reboot_suggested advisory. Requires rpm-software-management/dnf5#887 For rpm-software-management/dnf5#743
I'd like the DNF 5 needs-restarting command to behave a bit different from
dnf4 needs-restarting
. Here's what I propose:dnf5 needs-restarting
(no flag): I'd like this to simply report whether the system needs to be restarted. If there are "core packages" (such askernel
orglibc
) that have been updated since boot, or if any advisory with thereboot_suggested
flag applies to any of the packages that have been updated/installed since boot,dnf5 needs-restarting
will list these packages and exit with code 1 to indicate a reboot is needed. Otherwise, it will exit with code 0. This proposed behavior is the same as the current behavior ofdnf4 needs-restarting -r
, but it would properly honor thereboot_suggested
advisory rather than simply checking the hardcoded list of "core packages".I think this should be the default behavior of
needs-restarting
(rather than being behind a flag) because it's probably the most common use case. Here's an example of a user runningneeds-restarting
when they neededneeds-restarting -r
: https://bugzilla.redhat.com/show_bug.cgi?id=2237223.Regarding the behavior of
dnf4 needs-restarting
(no flag): currently, this command lists processes with open outdated files and recommends the user restart them. I think we should leave this behavior out ofdnf5 needs-restarting
for two reasons. First, tracer anddnf-plugins-extras-tracer
implement this approach well, and we don't need to duplicate their functionality. Second, this whole strategy of looking for open files is a bit of a hack and IMO shouldn't be included in the core DNF plugins. It might work most of the time, but there are nuances and edge cases here, e.g. when a process maps a library without opening it: https://bugzilla.redhat.com/show_bug.cgi?id=1131307, or if, hypothetically, a process reads a file into memory, closes it, then encrypts the copy in memory. There's just no way to tell that the process is "using" that outdated file.dnf5 needs-restarting -s
: I'd like this to list systemd services that need to be restarted, but rather than check whether the service has any open outdated files, check the dependencies of the package that provides the service. I haven't implemented this yet in this PR, but here's an outline:For #743
Resolves #587