From daaf3cea58f4065e9e938c0c76ecd5d302ec7969 Mon Sep 17 00:00:00 2001 From: Tomas Fratrik Date: Mon, 28 Apr 2025 14:19:01 +0200 Subject: [PATCH 22/37] Improve report of unsupported network configuration * Remove KCS from summary since it is present in the related links. * Generalize KCS title when using Kernel-Assigned NIC Names. * Show KCS about unsupported network configuration device types only when IPU 8 -> 9. * Adjust unit tests to reflect this change. Jira: RHEL-77175 --- .../actors/persistentnetnamesdisable/actor.py | 24 ++++++---- .../tests/test_persistentnetnamesdisable.py | 46 +++++++++++++++++-- 2 files changed, 56 insertions(+), 14 deletions(-) diff --git a/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py b/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py index 1f7f1413..1add3588 100644 --- a/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py +++ b/repos/system_upgrade/common/actors/persistentnetnamesdisable/actor.py @@ -2,6 +2,7 @@ import re from leapp import reporting from leapp.actors import Actor +from leapp.libraries.common.config.version import get_target_major_version from leapp.models import KernelCmdlineArg, PersistentNetNamesFacts from leapp.reporting import create_report, Report from leapp.tags import FactsPhaseTag, IPUWorkflowTag @@ -39,26 +40,31 @@ class PersistentNetNamesDisable(Actor): if self.single_eth0(interfaces): self.disable_persistent_naming() elif len(interfaces) > 1 and self.ethX_count(interfaces) > 0: - create_report([ + report_entries = [ reporting.Title('Unsupported network configuration'), reporting.Summary( 'Detected multiple physical network interfaces where one or more use kernel naming (e.g. eth0). ' 'Upgrade process can not continue because stability of names can not be guaranteed. ' - 'Please read the article at https://access.redhat.com/solutions/4067471 for more information.' ), reporting.ExternalLink( - title='How to perform an in-place upgrade to RHEL 8 when using kernel NIC names on RHEL 7', + title='How to Perform an In-Place Upgrade when Using Kernel-Assigned NIC Names', url='https://access.redhat.com/solutions/4067471' ), - reporting.ExternalLink( - title='RHEL 8 to RHEL 9: inplace upgrade fails at ' - '"Network configuration for unsupported device types detected"', - url='https://access.redhat.com/solutions/7009239' - ), reporting.Remediation( hint='Rename all ethX network interfaces following the attached KB solution article.' ), reporting.Severity(reporting.Severity.HIGH), reporting.Groups([reporting.Groups.NETWORK]), reporting.Groups([reporting.Groups.INHIBITOR]) - ]) + ] + + if get_target_major_version() == '9': + report_entries.append( + reporting.ExternalLink( + title='RHEL 8 to RHEL 9: inplace upgrade fails at ' + '"Network configuration for unsupported device types detected"', + url='https://access.redhat.com/solutions/7009239' + ) + ) + + create_report(report_entries) diff --git a/repos/system_upgrade/common/actors/persistentnetnamesdisable/tests/test_persistentnetnamesdisable.py b/repos/system_upgrade/common/actors/persistentnetnamesdisable/tests/test_persistentnetnamesdisable.py index 96768da9..95b695c0 100644 --- a/repos/system_upgrade/common/actors/persistentnetnamesdisable/tests/test_persistentnetnamesdisable.py +++ b/repos/system_upgrade/common/actors/persistentnetnamesdisable/tests/test_persistentnetnamesdisable.py @@ -1,3 +1,6 @@ +import pytest + +from leapp.libraries.common.config import version from leapp.models import Interface, KernelCmdlineArg, PCIAddress, PersistentNetNamesFacts from leapp.reporting import Report from leapp.snactor.fixture import current_actor_context @@ -14,7 +17,11 @@ def test_actor_single_eth0(current_actor_context): assert not current_actor_context.consume(Report) -def test_actor_more_ethX(current_actor_context): +@pytest.mark.parametrize( + 'target_version', ['9', '10'] +) +def test_actor_more_ethX(monkeypatch, current_actor_context, target_version): + monkeypatch.setattr(version, 'get_target_major_version', lambda: target_version) pci1 = PCIAddress(domain="0000", bus="3e", function="00", device="PCI bridge") pci2 = PCIAddress(domain="0000", bus="3d", function="00", device="Serial controller") interface = [Interface(name="eth0", mac="52:54:00:0b:4a:6d", vendor="redhat", @@ -25,8 +32,20 @@ def test_actor_more_ethX(current_actor_context): devpath="/devices/hidraw/hidraw0")] current_actor_context.feed(PersistentNetNamesFacts(interfaces=interface)) current_actor_context.run() - assert current_actor_context.consume(Report) - assert is_inhibitor(current_actor_context.consume(Report)[0].report) + + report_fields = current_actor_context.consume(Report)[0].report + assert is_inhibitor(report_fields) + + external_links = report_fields.get('detail', {}).get('external', []) + + rhel8to9_present = any( + 'RHEL 8 to RHEL 9' in link.get('title', '') for link in external_links + ) + + if target_version == '9': + assert rhel8to9_present + else: + assert not rhel8to9_present def test_actor_single_int_not_ethX(current_actor_context): @@ -39,7 +58,11 @@ def test_actor_single_int_not_ethX(current_actor_context): assert not current_actor_context.consume(Report) -def test_actor_ethX_and_not_ethX(current_actor_context): +@pytest.mark.parametrize( + 'target_version', ['9', '10'] +) +def test_actor_ethX_and_not_ethX(monkeypatch, current_actor_context, target_version): + monkeypatch.setattr(version, 'get_target_major_version', lambda: target_version) pci1 = PCIAddress(domain="0000", bus="3e", function="00", device="PCI bridge") pci2 = PCIAddress(domain="0000", bus="3d", function="00", device="Serial controller") interface = [Interface(name="virbr0", mac="52:54:00:0b:4a:6d", vendor="redhat", @@ -51,4 +74,17 @@ def test_actor_ethX_and_not_ethX(current_actor_context): current_actor_context.feed(PersistentNetNamesFacts(interfaces=interface)) current_actor_context.run() assert current_actor_context.consume(Report) - assert is_inhibitor(current_actor_context.consume(Report)[0].report) + + report_fields = current_actor_context.consume(Report)[0].report + assert is_inhibitor(report_fields) + + external_links = report_fields.get('detail', {}).get('external', []) + + rhel8to9_present = any( + 'RHEL 8 to RHEL 9' in link.get('title', '') for link in external_links + ) + + if target_version == '9': + assert rhel8to9_present + else: + assert not rhel8to9_present -- 2.49.0