leapp-repository/SOURCES/0067-fix-unsupported-source-version-crash.patch
2025-12-01 09:14:24 +00:00

120 lines
6.0 KiB
Diff

From 2b4d631e975235e2b517fd7a942136e6cc33ed12 Mon Sep 17 00:00:00 2001
From: Peter Mocary <pmocary@redhat.com>
Date: Mon, 10 Nov 2025 08:42:14 +0100
Subject: [PATCH 67/69] fix unsupported source version crash
This patch fixes a crash when executing upgrade on a system with version
that is not defined in the supported upgrade paths map and when the
fallback mechanism for this particular case fails as well. The upgrade
process is now terminated with an error instead of a trace back.
Jira: RHEL-120252
---
commands/upgrade/util.py | 18 ++++++----
.../libraries/ipuworkflowconfig.py | 34 +++++++++++++------
2 files changed, 34 insertions(+), 18 deletions(-)
diff --git a/commands/upgrade/util.py b/commands/upgrade/util.py
index da319448..1dbc0abd 100644
--- a/commands/upgrade/util.py
+++ b/commands/upgrade/util.py
@@ -263,14 +263,18 @@ def prepare_configuration(args):
# Check upgrade path and fail early if it's invalid
target_version, flavor = command_utils.get_target_release(args)
- os.environ['LEAPP_UPGRADE_PATH_TARGET_RELEASE'] = target_version
- os.environ['LEAPP_UPGRADE_PATH_FLAVOUR'] = flavor
-
current_version = command_utils.get_os_release_version_id('/etc/os-release')
- os.environ['LEAPP_IPU_IN_PROGRESS'] = '{source}to{target}'.format(
- source=command_utils.get_major_version_from_a_valid_version(current_version),
- target=command_utils.get_major_version_from_a_valid_version(target_version)
- )
+ if current_version and target_version:
+ os.environ['LEAPP_UPGRADE_PATH_TARGET_RELEASE'] = target_version
+ os.environ['LEAPP_IPU_IN_PROGRESS'] = '{source}to{target}'.format(
+ source=command_utils.get_major_version_from_a_valid_version(current_version),
+ target=command_utils.get_major_version_from_a_valid_version(target_version)
+ )
+ else:
+ # Setting these variables to prevent them being set outside of the leapp environment
+ os.environ['LEAPP_UPGRADE_PATH_TARGET_RELEASE'] = ''
+ os.environ['LEAPP_IPU_IN_PROGRESS'] = ''
+ os.environ['LEAPP_UPGRADE_PATH_FLAVOUR'] = flavor
configuration = {
'debug': os.getenv('LEAPP_DEBUG', '0'),
diff --git a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
index 828eee88..999a001e 100644
--- a/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
+++ b/repos/system_upgrade/common/actors/ipuworkflowconfig/libraries/ipuworkflowconfig.py
@@ -239,26 +239,38 @@ def _centos_to_rhel_supported_version_workaround(exposed_supported_paths):
def produce_ipu_config(actor):
flavour = os.environ.get('LEAPP_UPGRADE_PATH_FLAVOUR')
target_version = os.environ.get('LEAPP_UPGRADE_PATH_TARGET_RELEASE')
+ target_distro = os.environ.get('LEAPP_TARGET_OS')
os_release = get_os_release('/etc/os-release')
source_version = os_release.version_id
- target_distro = os.environ.get('LEAPP_TARGET_OS')
+ source_distro = os_release.release_id
+ all_upgrade_path_defs = load_upgrade_paths_definitions('upgrade_paths.json')
+ raw_upgrade_paths = extract_upgrade_paths_for_distro_and_flavour(all_upgrade_path_defs, source_distro, flavour)
+
+ if not target_version:
+ details = {}
+ if source_distro not in all_upgrade_path_defs:
+ details['details'] = 'This is due to an unsupported system distribution.'
+ elif source_version not in raw_upgrade_paths:
+ details['details'] = 'This is due to an unsupported source version of the system.'
+ details['hint'] = (
+ 'The in-place upgrade is possible only for the supported upgrade paths '
+ 'listed here: https://access.redhat.com/articles/4263361'
+ )
+ raise StopActorExecutionError(message='Could not determine the target version for the in-place upgrade.',
+ details=details)
check_target_major_version(source_version, target_version)
- all_upgrade_path_defs = load_upgrade_paths_definitions('upgrade_paths.json')
- raw_upgrade_paths = extract_upgrade_paths_for_distro_and_flavour(all_upgrade_path_defs,
- os_release.release_id,
- flavour)
- if os_release.release_id == target_distro:
+ if source_distro == target_distro:
raw_upgrade_paths = extract_upgrade_paths_for_distro_and_flavour(
- all_upgrade_path_defs, os_release.release_id, flavour
+ all_upgrade_path_defs, source_distro, flavour
)
else:
raw_upgrade_paths = make_cross_distro_paths(
- all_upgrade_path_defs, os_release.release_id, target_distro, flavour
+ all_upgrade_path_defs, source_distro, target_distro, flavour
)
- virtual_source_version = get_virtual_version(all_upgrade_path_defs, os_release.release_id, source_version)
+ virtual_source_version = get_virtual_version(all_upgrade_path_defs, source_distro, source_version)
virtual_target_version = get_virtual_version(all_upgrade_path_defs, target_distro, target_version)
source_major_version = source_version.split('.')[0]
@@ -266,7 +278,7 @@ def produce_ipu_config(actor):
raw_upgrade_paths, source_major_version
)
- if exposed_supported_paths and os_release.release_id == 'centos' and target_distro == 'rhel':
+ if exposed_supported_paths and source_distro == 'centos' and target_distro == 'rhel':
_centos_to_rhel_supported_version_workaround(exposed_supported_paths)
actor.produce(IPUConfig(
@@ -283,7 +295,7 @@ def produce_ipu_config(actor):
flavour=flavour,
supported_upgrade_paths=exposed_supported_paths,
distro=Distro(
- source=os_release.release_id,
+ source=source_distro,
target=target_distro,
),
))
--
2.51.1