From e6895c8556587a298f46f1493b7ac5b6344203d3 Mon Sep 17 00:00:00 2001 From: Dmitry Shibut Date: Fri, 10 Jan 2025 14:58:33 +0400 Subject: [PATCH] Change certain DNF command failures to throw StopActorExecutionError error instead of CalledProcessError When certain DNF commands fail, an unhandled CalledProcessError is thrown, halting the process and preventing cleanup actors from executing during preupgrade. Replacing it with StopActorExecutionError ensures the process still fails but executes the required actors. --- .../common/libraries/dnfconfig.py | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/repos/system_upgrade/common/libraries/dnfconfig.py b/repos/system_upgrade/common/libraries/dnfconfig.py index 1ca8700962..d0a8e319c5 100644 --- a/repos/system_upgrade/common/libraries/dnfconfig.py +++ b/repos/system_upgrade/common/libraries/dnfconfig.py @@ -105,9 +105,16 @@ def _set_excluded_pkgs(context, pkglist, disable_plugins): try: context.call(cmd) - except CalledProcessError: + except CalledProcessError as e: api.current_logger().error('Cannot set the dnf configuration') - raise + raise StopActorExecutionError( + message='Cannot set the DNF configuration with the command: {}'.format(cmd), + details={ + 'details': 'An exception raised: {}'.format(str(e)), + 'stdout': e.stdout, + 'stderr': e.stderr + } + ) api.current_logger().debug('The DNF configuration has been updated to exclude leapp packages.') @@ -147,7 +154,14 @@ def _set_repository_state(context, repo_id, new_state): try: context.call(cmd) - except CalledProcessError: + except CalledProcessError as e: api.current_logger().error('Cannot set the dnf configuration') - raise + raise StopActorExecutionError( + message='Cannot set the DNF configuration with the command: {}'.format(cmd), + details={ + 'details': 'An exception raised: {}'.format(str(e)), + 'stdout': e.stdout, + 'stderr': e.stderr + } + ) api.current_logger().debug('Repository {} has been {}'.format(repo_id, new_state))