Description of problem: Version-Release number of selected component (if applicable): yum-utils-4.0.21-11.el8.noarch Steps to Reproduce: 1. yum update zlib 2. needs-restarting -s 3. Actual results: # needs-restarting -s Updating Subscription Management repositories. Failed to read PID 4813's smaps. systemd-udevd.service rsyslog.service auditd.service pmie.service pmlogger.service systemd-journald.service sssd.service dbus.service <<<<<<< pmcd.service NetworkManager.service firewalld.service pmlogger_farm.service rpcbind.service sshd.service gssproxy.service pmie_farm.service user rngd.service systemd-logind.service Expected results: If dbus must be restarted, the system should be rebooted. Additional info:
The option `-s` only reports affected systemd services, but doesn't report whether a reboot is required. What does `dnf needs-restarting -r` report?
I should have included that at the start. ~~~~~~~~~~~~~~~~ [root@r8 ~]# needs-restarting -r Updating Subscription Management repositories. No core libraries or services have been updated since boot-up. Reboot should not be necessary. [root@r8 ~]# needs-restarting -s Updating Subscription Management repositories. rsyslog.service sshd.service pmlogger.service gssproxy.service rpcbind.service firewalld.service rngd.service auditd.service sssd.service systemd-logind.service NetworkManager.service pmcd.service systemd-journald.service pmie_farm.service pmlogger_farm.service systemd-udevd.service pmie.service ~~~~~~~~~~~~~~~~ The reboot will only show when certain packages are updated. REBOOTPKGS = ['kernel', 'kernel-rt', 'glibc', 'linux-firmware', 'systemd', 'udev', 'openssl-libs', 'gnutls', 'dbus'] In this case, zlib is triggering a need to restart dbus, but not saying it needs to reboot.
Reproduces (using expat instead ov zlib, though - unlike zlib, expat is direct dependency of dbus): # dnf repoquery --requires dbus-daemon Updating Subscription Management repositories. Last metadata expiration check: 0:17:16 ago on Mon Jun 13 08:18:55 2022. --------------------- 8< ---------------------- libexpat.so.1()(64bit) --------------------- 8< ---------------------- # dnf downgrade expat --------------------- 8< ---------------------- Downgraded: expat-2.2.5-4.el8_5.3.x86_64 # dnf needs-restarting -s Updating Subscription Management repositories. polkit.service tuned.service dbus.service # dnf needs-restarting -r Updating Subscription Management repositories. No core libraries or services have been updated since boot-up. Reboot should not be necessary. # echo $? 0
The binary package is built from dnf-plugins-core. Moving a component there.
I think there is a flaw in a logic for the "-r" option in needs_restarting.py: def run(self): process_start = ProcessStart() owning_pkg_fn = functools.partial(owning_package, self.base.sack) owning_pkg_fn = memoize(owning_pkg_fn) opt = get_options_from_dir(os.path.join( self.base.conf.installroot, "etc/dnf/plugins/needs-restarting.d/"), self.base) NEED_REBOOT.extend(opt) if self.opts.reboothint: need_reboot = set() installed = self.base.sack.query().installed() for pkg in installed.filter(name=NEED_REBOOT): → if pkg.installtime > process_start.boot_time: need_reboot.add(pkg.name) if need_reboot: print(_('Core libraries or services have been updated ' 'since boot-up:')) for name in sorted(need_reboot): print(' * %s' % name) print() print(_('Reboot is required to fully utilize these updates.')) print(_('More information:'), 'https://access.redhat.com/solutions/27943') raise dnf.exceptions.Error() # Sets exit code 1 else: print(_('No core libraries or services have been updated ' 'since boot-up.')) The current code ends up with "No core libraries or services have been updated since boot-up." message because all it does is checking an installation time of the very few packages listed in NEED_REBOOT array against uptime of the system. In this case a library used by dbus program was updated. But that library is not part of dbus RPM package. It's comes from a different package (e.g. zlib) which is not on the list. A proper fix needs to enumerate affected processes, locate their programs, map them to binary RPM package, consult the packages against the NEED_REBOOT array. needs-restaring without options already locates the program ("needs-restarting | grep dbus"). All you need is query a sack for a package providing the program file and then match NEED_REBOOT without checking any installation times.
Now I realize that replacing the original approach would introduce regressions like "I upgraded linux-firmware and it does report to reboot because on process holds open firmware file". I think we need to combine both approaches. Checking for open files and checking for installation time, do union on both sets.
Hello, unfortunately, we are postponing this fix to 8.9. The risk of this bugfix having collateral side effects is high. Therefore, we would like to have more time to test it in Fedora.