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 2175229

Summary: [RFE] [leapp] Add custom drivers during the IPU
Product: Red Hat Enterprise Linux 7 Reporter: Christophe Besson <cbesson>
Component: leapp-repositoryAssignee: Leapp Notifications Bot <leapp-notifications-bot>
Status: CLOSED MIGRATED QA Contact: upgrades-and-conversions
Severity: low Docs Contact:
Priority: low    
Version: 7.9CC: pstodulk
Target Milestone: rcKeywords: FutureFeature, MigratedToJIRA, Triaged
Target Release: ---Flags: pm-rhel: mirror+
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Enhancement
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2023-09-12 12:43:25 UTC Type: Story
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:

Description Christophe Besson 2023-03-03 15:54:30 UTC
Description of problem:
Using custom drivers is basically unsupported as it could be risky and in the worst case lead to a broken system.

That said, it would be a great feature and a customer requested how to do this. As they agreed to make some tests in their environment I suggested the below recipe.

Customer is using a NAS that uses arcmsr as a storage driver. This driver was present in the RHEL7 branch but has been removed from RHEL 8 and beyond.

The procedure worked for the customer.

Version-Release number of selected component (if applicable):
leapp-upgrade-el7toel8-0.17.0-1.el7_9

DISCLAIMER: it's not supported by Red Hat, play at your own risk!


0. Avoid the inhibitor and edit `/etc/leapp/files/device_driver_deprecation_data.json` to make Leapp believe it's still available and maintained:
    {
      "available_in_rhel": [
        7, 8
      ],
      "deprecation_announced": "",
      "device_id": "",
      "device_name": "",
      "device_type": "pci",
      "driver_name": "arcmsr",
      "maintained_in_rhel": [ 7, 8 ]
    },

1. Create an HTTP repo on *another* machine to share the RPM driver.
Ensure you can curl the metadata (repodata/repomd.xml) and the rpm from the target machine.

2. On the target machine, create an additional repo (replace 192.168.122.1 by the IP of the http server used above).

# cat << EOF > /etc/leapp/files/leapp_upgrade_repositories.repo
[drivers]
name=drivers
baseurl=http://192.168.122.1/drivers
EOF

3. Include the RPM in the el8 target userspace container used to create the UpgradeInitramfs (/var/lib/leapp/el8userspace). To do so, edit `/usr/share/leapp-repository/repositories/system_upgrade/common/actors/commonleappdracutmodules/libraries/modscan.py`, and add 'kmod-arcmsr' to the _REQUIRED_PACKAGES array.

 15 _REQUIRED_PACKAGES = [
 16     'binutils',
 17     'cifs-utils',
 18     'device-mapper-multipath',
 19     'dracut',
 20     'dracut-config-generic',
 21     'dracut-config-rescue',
 22     'dracut-network',
 23     'dracut-tools',
 24     'fcoe-utils',
 25     'hostname',
 26     'iscsi-initiator-utils',
 27     'kbd',
 28     'kernel',
 29     'kernel-core',
 30     'kernel-modules',
 31     'keyutils',
 32     'lldpad',
 33     'lvm2',
 34     'mdadm',
 35     'nfs-utils',
 36     'openssh-clients',
 37     'plymouth',
 38     'rpcbind',
 39     'systemd-container',
 40     'tar',
 41     'kmod-arcmsr',          # <<<<<
 42 ]

4. Edit `/usr/share/leapp-repository/repositories/system_upgrade/common/actors/initramfs/upgradeinitramfsgenerator/files/generate-initram.sh` and insert the following line: --add-drivers arcmsr

 81     stage "Building initram disk for kernel: $KERNEL_VERSION"
 82     \dracut \
 83         -vvvv \
 84         --force \
 85         --conf "$DRACUT_CONF" \
 86         --confdir "$DRACUT_CONF_DIR" \
 87         --install "$DRACUT_INSTALL" \
 88         $DRACUT_MODULES_ADD \
 89         "$DRACUT_MDADMCONF_ARG" \
 90         "$DRACUT_LVMCONF_ARG" \
 91         --no-hostonly \
 92         --add-drivers arcmsr \                # <<<<<
 93         --kver "$KERNEL_VERSION" \
 94         --kernel-image "vmlinuz-upgrade.$KERNEL_ARCH" \
 95         "initramfs-upgrade.${KERNEL_ARCH}.img"

5. Tell Leapp to add this RPM to be installed during the DNF transaction on the final target system

# echo kmod-arcmsr >> /etc/leapp/transaction/to_install

6. Run `leapp upgrade --debug --enablerepo drivers`

Comment 2 Petr Stodulka 2023-06-08 19:21:41 UTC
Hi, just giving an update this is going to be delivered by upstream PR:
* https://github.com/oamg/leapp-repository/pull/1081

The solution expect creation of custom actor that generates required msgs to
* install the package inside the target userspace container (TargetUserspaceUpgradeTasks)
* install the package on the system during the upgrade (RpmTransactionTasks)
* install the driver inside the upgrade initramfs (UpgradeInitramfsTasks)
* install the driver inside the target initramfs - for the upgraded system (TargetInitramfsTasks

The example below expects the custom repository is defined alraedy inside
    /etc/leapp/files/leapp_upgrade_repositories.repo


Disclaimer:
The code of a possible custom actor below is untested and I am appending it here just to provide
a picture how this could be in future (most likely) solved with the upcoming changes. It's still
possible that some changes could happen yet before the release, but currently this is what we expect.

It seems little bit longer due to number of comments as I prepared it for the possible future template
for other similar cases. I understand that better would be the possibility to configure just configure
the upgrade in this case, but that's plan for another future feature.

~~~
from leapp.actors import Actor
from leapp.models import (
    KernelModule,
    RpmTransactionTasks,
    TargetInitramfsTasks,
    TargetUserSpaceUpgradeTasks,
    UpgradeInitramfsTasks
)
from leapp.tags import ChecksPhaseTag, IPUWorkflowTag


class AddKernelDriverArcmsr(Actor):
    """
    Install the driver arcmsr driver during the upgrade

    Install the arcmsr kernel module in the upgrade & target initramfs.
    In this scenario it requires the package with the module is installed
    on the target system and inside the target userspace container.

    In case of the scenario when the module should be copied from a directory
    existing on the host system, specify the path from where it should
    be copied/installed instead, e.g.:
        KernelModule(name='arcmsr', module_path='/path/to/the/module')
    """

    name = 'addkerneldriverarcmsr'
    consumes = ()
    produces = (RpmTransactionTasks, TargetInitramfsTasks, TargetUserSpaceUpgradeTasks, UpgradeInitramfsTasks)
    tags = (IPUWorkflowTag, ChecksPhaseTag)

    def process(self):
        # IMPORTANT: For these package installations the (custom) repository
        # must be enabled! Ideal solution is to define the repos inside the
        # /etc/leapp/files/leapp_upgrade_repositories.repo file or using the
        # --enablerepo option when running leapp.
        # this will create task to install the package with desired driver
        # into the target userspace container
        self.produce(TargetUserSpaceUpgradeTasks(install_rpms=['kmod-arcmsr']))

        # and we want the package to be installed also during the upgrade,
        # so the driver can be used also on the upgraded system
        self.produce(RpmTransactionTasks(to_install=['kmod-arcmsr']))

        # this will require installation of the module in the upgrade and the
        # target initramfs
        k_module = KernelModule(name='arcmsr')
        self.produce(UpgradeInitramfsTasks(include_kernel_modules=[k_module]))
        self.produce(TargetInitramfsTasks(include_kernel_modules=[k_module]))
~~~

Comment 3 RHEL Program Management 2023-09-12 12:42:27 UTC
Issue migration from Bugzilla to Jira is in process at this time. This will be the last message in Jira copied from the Bugzilla bug.

Comment 4 RHEL Program Management 2023-09-12 12:43:25 UTC
This BZ has been automatically migrated to the issues.redhat.com Red Hat Issue Tracker. All future work related to this report will be managed there.

Due to differences in account names between systems, some fields were not replicated.  Be sure to add yourself to Jira issue's "Watchers" field to continue receiving updates and add others to the "Need Info From" field to continue requesting information.

To find the migrated issue, look in the "Links" section for a direct link to the new issue location. The issue key will have an icon of 2 footprints next to it, and begin with "RHEL-" followed by an integer.  You can also find this issue by visiting https://issues.redhat.com/issues/?jql= and searching the "Bugzilla Bug" field for this BZ's number, e.g. a search like:

"Bugzilla Bug" = 1234567

In the event you have trouble locating or viewing this issue, you can file an issue by sending mail to rh-issues. You can also visit https://access.redhat.com/articles/7032570 for general account information.