Description of problem: "dnf needs-restarting -r" work incorrectly inside systemd-nspawn containers Version-Release number of selected component (if applicable): source: dnf-plugins-core-4.0.18-1.fc33.src.rpm binary: python3-dnf-plugins-core-4.0.18-1.fc33.noarch.rpm How reproducible: always 1. Install Fedora Server 33 on host, install systemd-container package on host: dnf install systemd-container 2. Install Fedora Server 33 inside systemd-nspawn container: dnf --installroot=/var/lib/machines/test --releasever=33 install dnf python3-dnf-plugins-core systemd 3. start container test: machinectl start test 4. enter inside container test: machinectl shell test 5. check if container needs restarting: dnf needs-restarting -r Actual results: # dnf needs-restarting -r Core libraries or services have been updated since boot-up: * dbus * dbus-broker * glibc * systemd Reboot is required to fully utilize these updates. More information: https://access.redhat.com/solutions/27943 Expected results: # dnf needs-restarting -r No core libraries or services have been updated since boot-up. Reboot should not be necessary. Additional info: Cause of bug located in file: /usr/lib/python3.6/site-packages/dnf-plugins/needs_restarting.py Linus Torvalds say: "Talk is cheap. Show me the code". Ok. Patch to solve this bug: After this patch - command "dnf needs-restarting -r" will work correctly inside and outside systemd-nspawn containers. The first process start time could be used as container/host start time: int(os.stat('/proc/1/cmdline').st_mtime) /proc/1/cmdline is a virtual file in the procfs, whose creation date is the same as the container creation date or linux host boot time, if no containers is used. --- needs_restarting.py.orig 2020-10-06 19:54:52.000000000 +0300 +++ needs_restarting.py 2021-01-08 14:13:39.465000000 +0200 @@ -174,11 +174,7 @@ @staticmethod def get_boot_time(): - with open('/proc/stat') as stat_file: - for line in stat_file.readlines(): - if not line.startswith('btime '): - continue - return int(line[len('btime '):].strip()) + return int(os.stat('/proc/1/cmdline').st_mtime) @staticmethod def get_sc_clk_tck():
I added a PR with your patch https://github.com/rpm-software-management/dnf-plugins-core/pull/422
tests: https://github.com/rpm-software-management/ci-dnf-stack/pull/938
FEDORA-2021-447fb19490 has been submitted as an update to Fedora 33. https://bodhi.fedoraproject.org/updates/FEDORA-2021-447fb19490
FEDORA-2021-447fb19490 has been pushed to the Fedora 33 testing repository. Soon you'll be able to install the update with the following command: `sudo dnf upgrade --enablerepo=updates-testing --advisory=FEDORA-2021-447fb19490` You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2021-447fb19490 See also https://fedoraproject.org/wiki/QA:Updates_Testing for more information on how to test updates.
FEDORA-2021-447fb19490 has been pushed to the Fedora 33 stable repository. If problem still persists, please make note of it in this bug report.