leapp-repository/SOURCES/0042-el8toel9-Warn-about-the-NVIDIA-driver-before-upgrade.patch
2022-08-17 09:25:14 +00:00

108 lines
4.9 KiB
Diff

From efa3becc424438b3904013310d6a8b7ec675ae6a Mon Sep 17 00:00:00 2001
From: Niels De Graef <ndegraef@redhat.com>
Date: Tue, 12 Apr 2022 13:08:31 +0200
Subject: [PATCH 42/47] el8toel9: Warn about the NVIDIA driver before upgrade
---
.../actors/nvidiaproprietarydriver/actor.py | 47 +++++++++++++++++++
.../tests/test_nvidiadriver.py | 33 +++++++++++++
2 files changed, 80 insertions(+)
create mode 100644 repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/actor.py
create mode 100644 repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/tests/test_nvidiadriver.py
diff --git a/repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/actor.py b/repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/actor.py
new file mode 100644
index 00000000..7397f3e2
--- /dev/null
+++ b/repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/actor.py
@@ -0,0 +1,47 @@
+from leapp import reporting
+from leapp.actors import Actor
+from leapp.models import ActiveKernelModulesFacts
+from leapp.reporting import create_report, Report
+from leapp.tags import ChecksPhaseTag, IPUWorkflowTag
+
+
+class CheckNvidiaProprietaryDriver(Actor):
+ """
+ Check if NVIDIA proprietary driver is in use. If yes, inhibit the upgrade process.
+
+ Updating bare metal (or VM) with the binary NVIDIA driver will end up with a blacklisted nouveau.
+
+ See also https://bugzilla.redhat.com/show_bug.cgi?id=2057026
+ """
+
+ name = 'check_nvidia_proprietary_driver'
+ consumes = (ActiveKernelModulesFacts,)
+ produces = (Report,)
+ tags = (ChecksPhaseTag, IPUWorkflowTag)
+
+ def process(self):
+
+ for fact in self.consume(ActiveKernelModulesFacts):
+ nvidia_driver_loaded = any('nvidia' in active_mod.filename for active_mod in fact.kernel_modules)
+ if nvidia_driver_loaded:
+ create_report([
+ reporting.Title('Proprietary NVIDIA driver detected'),
+ reporting.Summary(
+ 'Leapp has detected that the NVIDIA proprietary driver has been loaded, which also means '
+ 'the nouveau driver is blacklisted. If you upgrade now, you will end up without a '
+ 'graphical session, as the newer kernel won\'t be able to load the NVIDIA driver module '
+ 'and nouveau will still be blacklisted.'
+ '\n\n'
+ 'Please uninstall the NVIDIA graphics driver before upgrading to make sure you have a '
+ 'graphical session after upgrading.'
+ ),
+ reporting.ExternalLink(
+ title='How to uninstall proprietary NVIDIA graphics driver and switch back to Red Hat '
+ 'shipped nouveau graphics driver?',
+ url='https://access.redhat.com/solutions/421683'
+ ),
+ reporting.Severity(reporting.Severity.HIGH),
+ reporting.Flags([reporting.Flags.INHIBITOR]),
+ reporting.Tags([reporting.Tags.KERNEL, reporting.Tags.DRIVERS]),
+ ])
+ break
diff --git a/repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/tests/test_nvidiadriver.py b/repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/tests/test_nvidiadriver.py
new file mode 100644
index 00000000..3cd299b0
--- /dev/null
+++ b/repos/system_upgrade/el8toel9/actors/nvidiaproprietarydriver/tests/test_nvidiadriver.py
@@ -0,0 +1,33 @@
+from leapp.models import ActiveKernelModule, ActiveKernelModulesFacts
+from leapp.reporting import Report
+
+
+def test_actor_with_nvidia_driver(current_actor_context):
+ with_nvidia = [
+ ActiveKernelModule(filename='nvidia', parameters=[]),
+ ActiveKernelModule(filename='kvm', parameters=[])]
+
+ current_actor_context.feed(ActiveKernelModulesFacts(kernel_modules=with_nvidia))
+ current_actor_context.run()
+ report_fields = current_actor_context.consume(Report)[0].report
+ assert 'inhibitor' in report_fields['flags']
+
+
+def test_actor_without_nvidia_driver(current_actor_context):
+ without_nvidia = [
+ ActiveKernelModule(filename='i915', parameters=[]),
+ ActiveKernelModule(filename='kvm', parameters=[])]
+
+ current_actor_context.feed(ActiveKernelModulesFacts(kernel_modules=without_nvidia))
+ current_actor_context.run()
+ assert not current_actor_context.consume(Report)
+
+
+def test_actor_with_nouveau_driver(current_actor_context):
+ without_nvidia = [
+ ActiveKernelModule(filename='nouveau', parameters=[]),
+ ActiveKernelModule(filename='kvm', parameters=[])]
+
+ current_actor_context.feed(ActiveKernelModulesFacts(kernel_modules=without_nvidia))
+ current_actor_context.run()
+ assert not current_actor_context.consume(Report)
--
2.35.3