From 333f05c11f72b9e5fb86efde856408f288c57466 Mon Sep 17 00:00:00 2001 From: Lubomir Rintel Date: Sun, 21 Jul 2024 00:05:34 +0200 Subject: [PATCH] el0toel10: Add actor that scans for deprecated network settings RHEL 10 is going to no longer support configuring NetworkManager to use the dhclient DHCP client (in fact, dhclient will not be present at all). Let's add an actor to deal with this sort of configuration. In particulare, make sure the users review their configuration, on chance they configured NM this way intentionally and they actually rely on some dhclient configuration or behavior. Jira: https://issues.redhat.com/browse/RHEL-46975 --- .../actors/networkdeprecations/actor.py | 46 +++++++++++++++++++ .../unit_test_networkdeprecations_9to10.py | 25 ++++++++++ 2 files changed, 71 insertions(+) create mode 100644 repos/system_upgrade/el9toel10/actors/networkdeprecations/actor.py create mode 100644 repos/system_upgrade/el9toel10/actors/networkdeprecations/tests/unit_test_networkdeprecations_9to10.py diff --git a/repos/system_upgrade/el9toel10/actors/networkdeprecations/actor.py b/repos/system_upgrade/el9toel10/actors/networkdeprecations/actor.py new file mode 100644 index 0000000000..94868476cf --- /dev/null +++ b/repos/system_upgrade/el9toel10/actors/networkdeprecations/actor.py @@ -0,0 +1,46 @@ +from leapp import reporting +from leapp.actors import Actor +from leapp.models import NetworkManagerConfig, Report +from leapp.tags import ChecksPhaseTag, IPUWorkflowTag + + +class CheckNetworkDeprecations9to10(Actor): + """ + Ensures that network configuration doesn't rely on unsupported settings + + Inhibits upgrade if the network configuration includes settings that + could possibly not work on the upgraded system. + + Includes check for dhclient DHCP plugin that will be removed from RHEL10. + """ + + name = "network_deprecations" + consumes = (NetworkManagerConfig,) + produces = (Report,) + tags = (ChecksPhaseTag, IPUWorkflowTag,) + + @staticmethod + def report_dhclient(): + title = 'Deprecated DHCP plugin configured' + summary = ('NetworkManager is configured to use the "dhclient" DHCP module.' + ' In Red Hat Enterprise Linux 10, this setting will be ignored' + ' along with any dhcp-client specific configuration.') + remediation = ('Remove "dhcp=internal" line from "[main]" section from all' + ' configuration files in "/etc/NetworkManager". Review' + ' configuration in "/etc/dhcp", which will be ignored.') + reporting.create_report([ + reporting.Title(title), + reporting.Summary(summary), + reporting.Remediation(hint=remediation), + reporting.Severity(reporting.Severity.HIGH), + reporting.Groups([reporting.Groups.NETWORK, reporting.Groups.SERVICES]), + reporting.Groups([reporting.Groups.INHIBITOR]), + reporting.RelatedResource('package', 'dhcp-client'), + reporting.RelatedResource('package', 'NetworkManager'), + ]) + + def process(self): + for nm_config in self.consume(NetworkManagerConfig): + self.log.info('Consuming dhcp={}'.format(nm_config.dhcp)) + if nm_config.dhcp == 'dhclient': + CheckNetworkDeprecations9to10.report_dhclient() diff --git a/repos/system_upgrade/el9toel10/actors/networkdeprecations/tests/unit_test_networkdeprecations_9to10.py b/repos/system_upgrade/el9toel10/actors/networkdeprecations/tests/unit_test_networkdeprecations_9to10.py new file mode 100644 index 0000000000..e71af0224d --- /dev/null +++ b/repos/system_upgrade/el9toel10/actors/networkdeprecations/tests/unit_test_networkdeprecations_9to10.py @@ -0,0 +1,25 @@ +from leapp.models import NetworkManagerConfig, Report + + +def test_dhcp_dhclient(current_actor_context): + current_actor_context.feed(NetworkManagerConfig(dhcp='dhclient')) + current_actor_context.run() + reports = list(current_actor_context.consume(Report)) + assert len(reports) == 1 + r = reports[0].report + assert r['title'] == 'Deprecated DHCP plugin configured' + assert r['severity'] == 'high' + + +def test_dhcp_internal(current_actor_context): + current_actor_context.feed(NetworkManagerConfig(dhcp='internal')) + current_actor_context.run() + reports = list(current_actor_context.consume(Report)) + assert len(reports) == 0 + + +def test_dhcp_default(current_actor_context): + current_actor_context.feed(NetworkManagerConfig()) + current_actor_context.run() + reports = list(current_actor_context.consume(Report)) + assert len(reports) == 0