Bug 2043538

Summary: yum needs_restarting reports wrong result after some time sfter update of critical packages
Product: Red Hat Enterprise Linux 8 Reporter: Dmitry <dovechkin>
Component: dnf-plugins-coreAssignee: Nicola Sella <nsella>
Status: CLOSED DUPLICATE QA Contact: swm-qe
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 8.3CC: james.antill, nsella
Target Milestone: rcKeywords: Triaged
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2022-03-15 14:32:12 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Dmitry 2022-01-21 13:33:12 UTC
Description of problem:
yum needs-restaring -r  returns 1 immediately and for some time after installation of critical packages, but after some time starts return 0

Reason is:
Script
/usr/lib/python3.6/site-packages/dnf-plugins/needs_restarting.py
compares package installtime with os boottime, and boottime assumed as:  

    def get_boot_time():
        return int(os.stat('/proc/1/cmdline').st_mtime)

but timestamp of st_mtime, seems updates from time to time.
For example on host, affected by problem: 

# stat /proc/1/cmdline
  File: /proc/1/cmdline
  Size: 0               Blocks: 0          IO Block: 1024   regular empty file
Device: 5h/5d   Inode: 40351045    Links: 1
Access: (0444/-r--r--r--)  Uid: (    0/    root)   Gid: (    0/    root)
Context: system_u:system_r:init_t:s0
Access: 2022-01-21 14:22:43.161122475 +0300
Modify: 2022-01-21 14:22:43.161122475 +0300
Change: 2022-01-21 14:22:43.161122475 +0300
 Birth: -
# uptime
 16:29:39 up 127 days,  5:10,  2 users,  load average: 0.15, 0.08, 0.06

Comment 1 Nicola Sella 2022-01-25 18:25:04 UTC
A patch to mitigate the issue was released on z-stream for 8.5 and y-stream

https://bugzilla.redhat.com/show_bug.cgi?id=2022389

Comment 2 Nicola Sella 2022-01-27 12:18:36 UTC
May I ask for more information on the system? Also, what version of dnf and plugins are you running?

Comment 3 Dmitry 2022-02-02 10:04:26 UTC
# cat /etc/redhat-release
Red Hat Enterprise Linux release 8.3 (Ootpa)

# rpm -qa | grep dnf
dnf-data-4.7.0-4.el8.noarch
dnf-plugins-core-4.0.21-3.el8.noarch
python3-libdnf-0.63.0-3.el8.x86_64
python3-dnf-4.7.0-4.el8.noarch
python3-dnf-plugins-core-4.0.21-3.el8.noarch
libdnf-0.63.0-3.el8.x86_64
dnf-plugin-subscription-manager-1.27.18-1.el8_3.x86_64
dnf-4.7.0-4.el8.noarch

Comment 4 Nicola Sella 2022-02-09 09:23:13 UTC
Thank you for being specific on the versions. From what I see, there is some mismatch between your RHEL version and dnf/dnf-plugins-core version.
dnf-4.7.0 and dnf-plugins-core-4.0.21 were released on 8.5, and I see that you have 8.3.

Did you update redhat-release package?
From which repository did you download dnf

Comment 5 Dmitry 2022-02-10 06:41:15 UTC
System is updated from standard redhat repository, but only security updates are installed.
For that reason redhat-release package is not updated.

Comment 6 Nicola Sella 2022-03-07 16:28:09 UTC
As I understand it, redhat-release shows a wrong version of rhel because it is not updated 
and dnf is not installed on 8.3 in the version you provided.
I believe this is related to rhel > 8.4 for which, we have addressed the issue from comment1.