Note: This bug is displayed in read-only format because
the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Description of problem:
"dnf needs-restarting -r" work incorrectly inside systemd-nspawn containers
Version-Release number of selected component (if applicable):
binary: python3-dnf-plugins-core-4.0.17-5.el8.noarch.rpm
source: dnf-plugins-core-4.0.17-5.el8.src.rpm
How reproducible:
always
Steps to Reproduce:
1. Install RHEL 8.3 / CentOS 8.3 on host, install systemd-container package on host:
dnf install systemd-container
2. Install RHEL 8.3 / CentOS 8.3 inside systemd-nspawn container:
yum --installroot=/var/lib/machines/test --releasever=8 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-daemon
* glibc
* systemd
Reboot is required to fully utilize these updates.
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-08-12 00:06:14.000000000 +0300
+++ needs_restarting.py 2021-01-07 22:27:20.779006509 +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():
Hello, thanks for the detailed explanation and solution proposed.
I am trying to reproduce the bug, but I am getting an error
$ machinectl start test
Job for systemd-nspawn failed because the control process exited with error code.
See "systemctl status systemd-nspawn" and "journalctl -xe" for details.
The error is related to SELinux policies, so I have to set SELinux Permissive to get through this error. Then, the bug seems reproducible.
Do you have any specific SELinux configuration? I would like to reproduce it with your configuration if possible.
Thank you
(In reply to nsella from comment #1)
> I am trying to reproduce the bug, but I am getting an error
>
> $ machinectl start test
> Job for systemd-nspawn failed because the control process
> exited with error code.
> See "systemctl status systemd-nspawn" and "journalctl -xe" for
> details.
>
> The error is related to SELinux policies, so I have to set SELinux
> Permissive to get through this error. Then, the bug seems reproducible.
> Do you have any specific SELinux configuration? I would like to reproduce it
> with your configuration if possible.
Yes, sorry, I forgot to write about SELinux.
I reproduce this bug with SELinux disabled:
1. Install RHEL 8.3 / CentOS 8.3 on host, install systemd-container package on host:
dnf install systemd-container
1.1. disable SELinux in /etc/selinux/config, write SELINUX=disabled
1.2. reboot
2. Install RHEL 8.3 / CentOS 8.3 inside systemd-nspawn container:
dnf --installroot=/var/lib/machines/test --releasever=8 install dnf python3-dnf-plugins-core systemd
...
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.
For information on the advisory (Moderate: dnf security and bug fix update), and where to find the updated
files, follow the link below.
If the solution does not work for you, open a new bug report.
https://access.redhat.com/errata/RHSA-2021:4464
Description of problem: "dnf needs-restarting -r" work incorrectly inside systemd-nspawn containers Version-Release number of selected component (if applicable): binary: python3-dnf-plugins-core-4.0.17-5.el8.noarch.rpm source: dnf-plugins-core-4.0.17-5.el8.src.rpm How reproducible: always Steps to Reproduce: 1. Install RHEL 8.3 / CentOS 8.3 on host, install systemd-container package on host: dnf install systemd-container 2. Install RHEL 8.3 / CentOS 8.3 inside systemd-nspawn container: yum --installroot=/var/lib/machines/test --releasever=8 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-daemon * glibc * systemd Reboot is required to fully utilize these updates. 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-08-12 00:06:14.000000000 +0300 +++ needs_restarting.py 2021-01-07 22:27:20.779006509 +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():