leapp-repository/SOURCES/0059-ipuconfig-Allow-for-one-of-the-virtual-version-to-be.patch
2025-12-01 09:14:24 +00:00

126 lines
6.3 KiB
Diff

From e32668ccc0320a02e3f48a76edcb0896545ab492 Mon Sep 17 00:00:00 2001
From: Matej Matuska <mmatuska@redhat.com>
Date: Mon, 15 Sep 2025 16:59:27 +0200
Subject: [PATCH 59/69] ipuconfig: Allow for one of the virtual version to be
missing
This is required for conversions.
The existing error message was improved to contain the key that is
actually missing in the virtual versions map.
Jira: RHEL-110563
---
.../libraries/ipuworkflowconfig.py | 50 +++++++++----------
.../tests/test_ipuworkflowconfig.py | 11 ++--
2 files changed, 30 insertions(+), 31 deletions(-)
diff --git a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
index dd84f3a1..afc139a1 100644
--- a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
+++ b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
@@ -117,9 +117,9 @@ def construct_models_for_paths_matching_source_major(raw_paths, src_major_versio
return multipaths_matching_source
-def construct_virtual_versions(all_upgrade_path_defs, distro_id, source_version, target_version):
- if distro_id.lower() != 'centos':
- return (source_version, target_version)
+def construct_virtual_version(all_upgrade_path_defs, distro, version):
+ if distro.lower() != 'centos':
+ return version
centos_upgrade_paths = all_upgrade_path_defs.get('centos', {})
if not centos_upgrade_paths:
@@ -127,27 +127,24 @@ def construct_virtual_versions(all_upgrade_path_defs, distro_id, source_version,
virtual_versions = centos_upgrade_paths.get(CENTOS_VIRTUAL_VERSIONS_KEY, {})
if not virtual_versions: # Unlikely, only if using old upgrade_paths.json, but the user should not touch the file
- details = {'details': 'The file does not contain any information about virtual versions of CentOS'}
- raise StopActorExecutionError('The internal upgrade_paths.json file is malformed.')
-
- source_virtual_version = virtual_versions.get(source_version)
- target_virtual_version = virtual_versions.get(target_version)
-
- if not source_virtual_version or not target_virtual_version:
- if not source_virtual_version and not target_virtual_version:
- what_is_missing = 'CentOS {} (source) and CentOS {} (target)'.format(source_virtual_version,
- target_virtual_version)
- elif not source_virtual_version:
- what_is_missing = 'CentOS {} (source)'.format(source_virtual_version)
- else:
- what_is_missing = 'CentOS {} (target)'.format(target_virtual_version)
-
- details_msg = 'The {} field in upgrade path definitions does not provide any information for {}'
- details = {'details': details_msg.format(CENTOS_VIRTUAL_VERSIONS_KEY, what_is_missing)}
- raise StopActorExecutionError('Failed to identify virtual minor version number for the system.',
- details=details)
+ details = {
+ "details": "The file does not contain any information about virtual versions of CentOS"
+ }
+ raise StopActorExecutionError(
+ "The internal upgrade_paths.json file is invalid.", details=details
+ )
- return (source_virtual_version, target_virtual_version)
+ virtual_version = virtual_versions.get(version)
+ if not virtual_version:
+ details = (
+ 'The {} field in upgrade path definitions for \'centos\' does not'
+ ' provide any virtual version for version {}'
+ ).format(CENTOS_VIRTUAL_VERSIONS_KEY, version)
+ raise StopActorExecutionError(
+ "Failed to identify virtual minor version number for the system.",
+ details={"details": details},
+ )
+ return virtual_version
def produce_ipu_config(actor):
@@ -165,12 +162,11 @@ def produce_ipu_config(actor):
source_major_version = source_version.split('.')[0]
exposed_supported_paths = construct_models_for_paths_matching_source_major(raw_upgrade_paths, source_major_version)
- virtual_source_version, virtual_target_version = construct_virtual_versions(all_upgrade_path_defs,
- os_release.release_id,
- source_version,
- target_version)
target_distro = os.environ.get('LEAPP_TARGET_OS')
+ virtual_source_version = construct_virtual_version(all_upgrade_path_defs, os_release.release_id, source_version)
+ virtual_target_version = construct_virtual_version(all_upgrade_path_defs, target_distro, target_version)
+
actor.produce(IPUConfig(
leapp_env_vars=get_env_vars(),
os_release=os_release,
diff --git a/repos/system_upgrade/common/actors/ipuworkflowconfig/tests/test_ipuworkflowconfig.py b/repos/system_upgrade/common/actors/ipuworkflowconfig/tests/test_ipuworkflowconfig.py
index 8b7faffb..96b63666 100644
--- a/repos/system_upgrade/common/actors/ipuworkflowconfig/tests/test_ipuworkflowconfig.py
+++ b/repos/system_upgrade/common/actors/ipuworkflowconfig/tests/test_ipuworkflowconfig.py
@@ -171,9 +171,12 @@ def test_load_raw_upgrade_paths_for_distro_and_flavour(monkeypatch, distro, flav
@pytest.mark.parametrize(
('construction_params', 'expected_versions'),
[
- (('centos', '8', '9'), ('8.10', '9.5')),
- (('rhel', '8.10', '9.4'), ('8.10', '9.4')),
- (('almalinux', '8.10', '9.6'), ('8.10', '9.6')),
+ (('centos', '8'), '8.10'),
+ (('centos', '9'), '9.5'),
+ (('rhel', '8.10'), '8.10'),
+ (('rhel', '9.4'), '9.4'),
+ (('almalinux', '8.10'), '8.10'),
+ (('almalinux', '9.6'), '9.6'),
]
)
def test_virtual_version_construction(construction_params, expected_versions):
@@ -208,5 +211,5 @@ def test_virtual_version_construction(construction_params, expected_versions):
},
}
- result = ipuworkflowconfig.construct_virtual_versions(defined_upgrade_paths, *construction_params)
+ result = ipuworkflowconfig.construct_virtual_version(defined_upgrade_paths, *construction_params)
assert result == expected_versions
--
2.51.1