diff --git a/leapp/actors/__init__.py b/leapp/actors/__init__.py index 2ea98354e..1432a284d 100644 --- a/leapp/actors/__init__.py +++ b/leapp/actors/__init__.py @@ -16,19 +16,6 @@ from leapp.workflows.api import WorkflowAPI -class ActorExitStatus(object): - SUCCESS = 'success' - STOP_ACTOR_EXECUTION = 'stop_actor_execution' - STOP_ACTOR_EXECUTION_ERROR = 'stop_actor_execution_error' - REQUEST_STOP_AFTER_PHASE = 'request_stop_after_phase' - - ALLOWED_VALUES = (SUCCESS, STOP_ACTOR_EXECUTION, STOP_ACTOR_EXECUTION_ERROR, REQUEST_STOP_AFTER_PHASE) - - @classmethod - def validate(cls, value): - return value in cls.ALLOWED_VALUES - - class Actor(object): """ The Actor class represents the smallest step in the workflow. It defines what kind @@ -305,22 +292,17 @@ def run(self, *args): """ Runs the actor calling the method :py:func:`process`. """ os.environ['LEAPP_CURRENT_ACTOR'] = self.name - exit_status = ActorExitStatus.SUCCESS try: self.process(*args) except StopActorExecution: - exit_status = ActorExitStatus.STOP_ACTOR_EXECUTION + pass except StopActorExecutionError as err: self.report_error(err.message, err.severity, err.details) - exit_status = ActorExitStatus.STOP_ACTOR_EXECUTION_ERROR except RequestStopAfterPhase: self._messaging.request_stop_after_phase() - exit_status = ActorExitStatus.REQUEST_STOP_AFTER_PHASE finally: os.environ.pop('LEAPP_CURRENT_ACTOR', None) - return {'status': exit_status} - def process(self, *args, **kwargs): """ Main processing method. In inherited actors, the function needs to be defined to be able to be processed.""" raise NotImplementedError() diff --git a/leapp/workflows/__init__.py b/leapp/workflows/__init__.py index c1a172557..553c52077 100644 --- a/leapp/workflows/__init__.py +++ b/leapp/workflows/__init__.py @@ -363,10 +363,8 @@ def run(self, context=None, until_phase=None, until_actor=None, skip_phases_unti instance = actor(logger=current_logger, messaging=messaging, config_model=config_model, skip_dialogs=skip_dialogs) - exit_status = None try: - result = instance.run() - exit_status = result['status'] + instance.run() except BaseException as exc: self._unhandled_exception = True messaging.report_stacktrace(message=exc.message, @@ -376,9 +374,13 @@ def run(self, context=None, until_phase=None, until_actor=None, skip_phases_unti trace=exc.exception_info)) raise finally: + # Set and unset the enviromental variable so that audit + # associates the entry with the correct data source + os.environ['LEAPP_CURRENT_ACTOR'] = actor.name create_audit_entry( event='actor-exit-status', - data={'exit_code': 1 if self._unhandled_exception else 0, 'exit_status': exit_status}) + data={'exit_status': 1 if self._unhandled_exception else 0}) + os.environ.pop('LEAPP_CURRENT_ACTOR') self._stop_after_phase_requested = messaging.stop_after_phase or self._stop_after_phase_requested