leapp-repository/0013-fix-userspacegen-add-exeception-handling-to-swapping.patch
Petr Stodulka cb46739ce0 IPU 9.7 -> 10.1: CTC 1 candidate 1
- Require leapp-framework >= 6.1
- Simplified use of the LiveMode experimental feature with additional enhancements
- Fix the check of deprecated PCI devices and drivers
- Add RHEL 10.1 product certificates
- Gracefully handle CentOS OS versioning style
- Ensure the leapp-upgrade-el9toel10 RPM is not touched during the upgrade transaction
- Create proper error message when swap of RHUI clients fails
- Introduced the --enable-experimental-feature to simplify use of experimental features
- Manage RPM GPG keys during the upgrade respecting used linux distributions
- Prevent a crach during post-upgrade phases when no custom SELinux modules needs to be migrated
- Update leapp upgrade data files
- Minor fixes in reports
- Resolves: RHEL-49402, RHEL-72544, RHEL-77175, RHEL-80334, RHEL-80335, RHEL-80336, RHEL-80550, RHEL-86689
2025-05-14 10:46:55 +02:00

69 lines
3.2 KiB
Diff

From 53f125b42f3e17354cc2d3e93b80fe089cf4c3b2 Mon Sep 17 00:00:00 2001
From: Michal Hecko <mhecko@redhat.com>
Date: Tue, 4 Mar 2025 14:42:44 +0100
Subject: [PATCH 13/37] fix(userspacegen): add exeception handling to swapping
of RHUI clients
Leapp swaps to RHUI target clients (uninstall source client+install
target client) in the scratch container to gain repository access.
To perform this step atomically, without loosing repository access
in between, `dnf shell` is invoked. The instruction as to which RPMs
should be uninstalled and which should be installed are given on
stdin of the `dnf shell` command. Currently, if we fail to swap clients
we crash with an unhandled exception `CalledProcessError` that contains
no information about what went wrong since the actual performed
transaction is hidden within the stdin of the process. This patch
adds error handling, so that we can tell that we have failed to swap
RHUI clients. Leapp's logs also contain the full DNF transaction as well
as possible explanations on why we failed.
jira-ref: RHEL-77945
---
.../libraries/userspacegen.py | 30 ++++++++++++++++++-
1 file changed, 29 insertions(+), 1 deletion(-)
diff --git a/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py b/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py
index 12736ab7..9fc96a52 100644
--- a/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py
+++ b/repos/system_upgrade/common/actors/targetuserspacecreator/libraries/userspacegen.py
@@ -1239,7 +1239,35 @@ def setup_target_rhui_access_if_needed(context, indata):
'shell'
]
- context.call(cmd, callback_raw=utils.logging_handler, stdin='\n'.join(dnf_transaction_steps))
+ try:
+ dnf_shell_instructions = '\n'.join(dnf_transaction_steps)
+ api.current_logger().debug(
+ 'Supplying the following instructions to the `dnf shell`: {}'.format(dnf_shell_instructions)
+ )
+ context.call(cmd, callback_raw=utils.logging_handler, stdin=dnf_shell_instructions)
+ except CalledProcessError as error:
+ api.current_logger().debug(
+ 'Failed to swap RHUI clients. This is likely because there are no repositories '
+ ' containing RHUI clients enabled, or we cannot access them.'
+ )
+ api.current_logger().debug(error)
+
+ swapping_clients_info_msg = 'Failed to swap `{0}` (source client{1}) with {2} (target client{3}).'
+ swapping_clients_info_msg = swapping_clients_info_msg.format(
+ ' '.join(indata.rhui_info.src_client_pkg_names),
+ '' if len(indata.rhui_info.src_client_pkg_names) == 1 else 's',
+ ' '.join(indata.rhui_info.target_client_pkg_names),
+ '' if len(indata.rhui_info.target_client_pkg_names) == 1 else 's',
+ )
+
+ details = {
+ 'details': swapping_clients_info_msg,
+ 'error': str(error)
+ }
+ raise StopActorExecutionError(
+ 'Failed to swap RHUI clients to establish content access',
+ details=details
+ )
_apply_rhui_access_postinstall_tasks(context, setup_info)
--
2.49.0