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.

Bug 2164835

Summary: [RFE] Request method to inspect RPM package if it requires a system reboot before install
Product: Red Hat Enterprise Linux 9 Reporter: Hakyong Do <hdo>
Component: dnfAssignee: Evan Goode <egoode>
Status: CLOSED WONTFIX QA Contact: swm-qe
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: 9.4CC: casantos, egoode, james.antill
Target Milestone: rcKeywords: FutureFeature, Triaged
Target Release: ---Flags: pm-rhel: mirror+
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: 2023-07-12 19:11:22 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:

Comment 5 Evan Goode 2023-02-13 15:38:09 UTC
Hi, thank you for your request. Could you please elaborate on what you are proposing? Do you need this functionality available in the command-line interface, something like a `dnf --would-need-restarting install kernel`? Or are you asking for API functionality only?

Currently, to determine whether a reboot is necessary after installing a package (e.g. for `dnf needs-restarting`), DNF checks the package name against a hardcoded list of "core" packages, which includes systemd, kernel, and dbus, among others. We could certainly expose this functionality through the API, but the logic there is not very sophisticated; I'm not sure how well it would meet your needs.

Evan

Comment 6 Hakyong Do 2023-02-28 14:58:29 UTC
Hi,

Thank you for your response. What customer want is they need method to identify packages which will require a reboot before installing it. The CU doesn't matter the functionality available in the command-line or API.

The reason why they need this functionality is they want postpone installing packages that require system reboot later and keep their service online to meet their SLA. If they are able to identify those packages, they will schedule another maintenance window to rebooting systems.

Thank you

Hakyong Do

Comment 7 Evan Goode 2023-03-10 21:44:50 UTC
As I understand it, the change which adds this functionality has already been merged due to https://bugzilla.redhat.com/show_bug.cgi?id=2124793, but it is not yet documented. I just opened https://github.com/rpm-software-management/dnf/pull/1906 to document it.

Once the changes land in RHEL, the customer should be able to use something like this Python snippet to detect whether installing a package will require a reboot:

```
import dnf

package = "glibc"

base = dnf.Base()
base.read_all_repos()
base.fill_sack()

base.install_specs([package])
base.resolve()

# Is reboot needed?
if base.reboot_needed():
    print("Reboot is recommended")
elif:
    print("Reboot should not be necessary")
```

We still need to decide an expected target version of arrival in RHEL.

Comment 8 Jaroslav Mracek 2023-03-21 11:59:17 UTC
I have another suggestion. The method `reboot_needed()` uses static list of packages that might require reboot, but this is not the best approach that we can use. In advisory there is a suggestion field that could propose a reboot - `<reboot_suggested>True</reboot_suggested>`. We might use that information to provide a suggestion. It is also a cheap in comparison to scanning file content of rpms and guessing based on that.

What do you think?

Comment 9 Jaroslav Mracek 2023-03-21 12:01:13 UTC
        <package name="pcp-pmda-redis" version="6.0.1" release="2.fc36" epoch="0" arch="armv7hl" src="https://download.fedoraproject.org/pub/fedora/linux/updates/36/armv7hl/p/pcp-pmda-redis-6.0.1-2.fc36.armv7hl.rpm">
          <filename>pcp-pmda-redis-6.0.1-2.fc36.armv7hl.rpm</filename>
          <reboot_suggested>True</reboot_suggested>
        </package>

Comment 10 Evan Goode 2023-07-12 19:11:22 UTC
We now have https://github.com/rpm-software-management/dnf5/issues/587 to track this use case in DNF 5, the upcoming package manager that will replace DNF in future versions of RHEL. We'll be thinking about it when we implement the needs-restarting plugin for DNF 5.

More advanced logic for "reboot needed" is probably not worth implementing in DNF 4 this late in its life cycle, and the existing logic isn't really something users should rely on, so I have decided to close https://github.com/rpm-software-management/dnf/pull/1906 and leave `base.reboot_needed()` undocumented. Closing this bug.