diff --git a/leapp-0008-More-failure-details.patch b/leapp-0008-More-failure-details.patch new file mode 100644 index 0000000000000000000000000000000000000000..3b1aa557aa5d6730e8849a564de61aba7d6af2f5 --- /dev/null +++ b/leapp-0008-More-failure-details.patch @@ -0,0 +1,125 @@ +From 7c9e51fe7757393384a43d4fcf19422a1f61ebbf Mon Sep 17 00:00:00 2001 +From: Weisson +Date: Fri, 23 Dec 2022 16:39:06 +0800 +Subject: [PATCH] Provide more failure information for debug propose. + +Signed-off-by: Weisson +--- + leapp/actors/__init__.py | 14 +++++++++++++- + leapp/exceptions.py | 7 +++++++ + leapp/utils/deprecation.py | 7 +++++++ + leapp/workflows/__init__.py | 1 - + 4 files changed, 27 insertions(+), 2 deletions(-) + +diff --git a/leapp/actors/__init__.py b/leapp/actors/__init__.py +index af133fe..81c96dd 100644 +--- a/leapp/actors/__init__.py ++++ b/leapp/actors/__init__.py +@@ -5,7 +5,8 @@ import sys + from leapp.compat import string_types + from leapp.dialogs import Dialog + from leapp.exceptions import (MissingActorAttributeError, RequestStopAfterPhase, StopActorExecution, +- StopActorExecutionError, WorkflowConfigNotAvailable, WrongAttributeTypeError) ++ StopActorExecutionError, WorkflowConfigNotAvailable, WrongAttributeTypeError, ++ ActorFailureException) + from leapp.models import DialogModel, Model + from leapp.models.error_severity import ErrorSeverity + from leapp.tags import Tag +@@ -14,6 +15,9 @@ from leapp.utils.i18n import install_translation_for_actor + from leapp.utils.meta import get_flattened_subclasses + from leapp.workflows.api import WorkflowAPI + ++from leapp.libraries.common import smc_interface ++import traceback ++ + + class Actor(object): + """ +@@ -331,6 +335,8 @@ class Actor(object): + def run(self, *args): + """ Runs the actor calling the method :py:func:`process`. """ + os.environ['LEAPP_CURRENT_ACTOR'] = self.name ++ ++ smc_state_file_path = os.environ.get("DEFAULT_JSON_STATE_PATH") or smc_interface.DEFAULT_JSON_STATE_PATH + try: + self.process(*args) + except StopActorExecution: +@@ -339,6 +345,12 @@ class Actor(object): + self.report_error(err.message, err.severity, err.details) + except RequestStopAfterPhase: + self._messaging.request_stop_after_phase() ++ except ActorFailureException as e: ++ smc_interface.update_progress_infomation(progress=None, progress_info=e.exec_information, err_no=e.exit_code, err_msg=str(e.message), path=smc_state_file_path) ++ raise e ++ except Exception as e: ++ smc_interface.update_progress_infomation(progress=None, progress_info=traceback.format_exc(), err_no=999, err_msg="actor failure", path=smc_state_file_path) ++ raise e + finally: + os.environ.pop('LEAPP_CURRENT_ACTOR', None) + +diff --git a/leapp/exceptions.py b/leapp/exceptions.py +index 7959cf2..3e30a37 100644 +--- a/leapp/exceptions.py ++++ b/leapp/exceptions.py +@@ -3,6 +3,13 @@ class LeappError(Exception): + super(LeappError, self).__init__(message) + self.message = message + ++class ActorFailureException(Exception): ++ def __init__(self, exception, exit_code, exec_information="", message="actor exception."): ++ self.message = message ++ self.exit_code = exit_code ++ self.exec_information = exec_information ++ self.exception = exception ++ super(Exception, self).__init__(message) + + class RepositoryConfigurationError(LeappError): + pass +diff --git a/leapp/utils/deprecation.py b/leapp/utils/deprecation.py +index d1647a9..a91863e 100644 +--- a/leapp/utils/deprecation.py ++++ b/leapp/utils/deprecation.py +@@ -2,10 +2,13 @@ import datetime + import inspect + import warnings + from collections import namedtuple ++from leapp import exceptions + + import six ++import os + + from leapp.models import Model ++from leapp.libraries.common import smc_interface + + + _suppressed_deprecations = set() +@@ -36,10 +39,14 @@ def suppress_deprecation(*suppressed_items): + def process_wrapper(*args, **kwargs): + # we need to remove later just items that we add right now + # added_items == new items we add now to ... ++ smc_state_file_path = os.environ.get("DEFAULT_JSON_STATE_PATH") or smc_interface.DEFAULT_JSON_STATE_PATH + added_items = set(suppressed_items) - _suppressed_deprecations + _suppressed_deprecations.update(added_items) + try: + return target_item(*args, **kwargs) ++ except exceptions.ActorFailureException as e: ++ smc_interface.update_progress_infomation(progress=None, progress_info=e.exec_information, err_no=e.exit_code, err_msg=str(e.message), path=smc_state_file_path) ++ raise e + finally: + # remove the added items + _suppressed_deprecations.difference_update(added_items) +diff --git a/leapp/workflows/__init__.py b/leapp/workflows/__init__.py +index 5b218b2..66b7710 100644 +--- a/leapp/workflows/__init__.py ++++ b/leapp/workflows/__init__.py +@@ -329,7 +329,6 @@ class Workflow(with_metaclass(WorkflowMeta)): + try: + instance.run() + except Exception as e: +- smc_interface.update_progress_infomation(progress=None, progress_info='fail', err_no=1, err_msg='Actor %s fails : %s' % (str(instance), str(e)), path=smc_state_file_path) + self._unhandled_exception = True + raise e + +-- +2.30.1 (Apple Git-130) + diff --git a/leapp.spec b/leapp.spec index aeae1019a4b137016e3a4fbb01a7f0629e8ebdaa..c80665737970a5d8dd3525a3e59766e2f2cb7922 100644 --- a/leapp.spec +++ b/leapp.spec @@ -1,4 +1,4 @@ -%define anolis_release .0.7 +%define anolis_release .0.8 # IMPORTANT: this is for the leapp-framework capability (it's not the real # version of the leapp). The capability reflects changes in api and whatever # functionality important from the point of repository. In case of @@ -44,6 +44,7 @@ Patch0004: leapp-0004-report-a-default-external-link.patch Patch0005: 0005-SMC-progress-indicator.patch Patch0006: leapp-0006-add-customrepo-command.patch Patch0007: leapp-0007-remove-failure-exit-code-check.patch +Patch0008: leapp-0008-More-failure-details.patch %if !0%{?fedora} %if %{with python3} @@ -169,6 +170,7 @@ Python 3 leapp framework libraries. %patch0005 -p1 %patch0006 -p1 %patch0007 -p1 +%patch0008 -p1 ################################################## # Build @@ -291,6 +293,9 @@ rm -f %{buildroot}/%{_bindir}/leapp # no files here %changelog +* Tue Dec 27 2022 Weisson - 0.12.0-1.0.8 +- Provide more failure information for debug propose. + * Fri Dec 23 2022 Weisson - 0.12.0-1.0.7 - [Bugfix] Leapp stops if any exception is thrown, the shortcut on exit-code check might cause problem.