diff --git a/pleskdistup/actions/common_checks.py b/pleskdistup/actions/common_checks.py index 828116c..25b8cff 100644 --- a/pleskdistup/actions/common_checks.py +++ b/pleskdistup/actions/common_checks.py @@ -652,5 +652,5 @@ def _do_check(self) -> bool: if len(kernel_devel_packages) <= 1: return True - self.description = self.description.format("\n\t- ".join([pkg[0] + "-" + pkg[1] for pkg, _ in kernel_devel_packages])) + self.description = self.description.format("\n\t- ".join([pkg + "-" + ver for pkg, ver in kernel_devel_packages])) return False diff --git a/pleskdistup/common/src/action.py b/pleskdistup/common/src/action.py index 25aa25c..fed5a43 100644 --- a/pleskdistup/common/src/action.py +++ b/pleskdistup/common/src/action.py @@ -395,7 +395,7 @@ def __enter__(self): def __exit__(self, *kwargs): # Do not remove the actions data if an error occurs because # customer will likely want to retry after correcting the error on their end - if self.error is not None and os.path.exists(self.path_to_actions_data): + if not self.is_failed() and os.path.exists(self.path_to_actions_data): os.remove(self.path_to_actions_data) def _get_flow(self) -> typing.Dict[str, typing.List[ActiveAction]]: diff --git a/pleskdistup/common/tests/actionstests.py b/pleskdistup/common/tests/actionstests.py index e9d6913..c104209 100644 --- a/pleskdistup/common/tests/actionstests.py +++ b/pleskdistup/common/tests/actionstests.py @@ -231,6 +231,26 @@ def test_finish_skip_based_on_skip_saved_state(self): def test_finish_skip_based_on_failed_saved_state(self): check_saved_state("finish", "test_finish_skip_based_on_failed_saved_state", "failed", False) + def test_actions_json_removed(self): + simple_action = SimpleAction() + simple_action._post_action = mock.Mock(return_value=action.ActionResult()) + with FinishActionsFlowForTests({"test_one_simple_action": [simple_action]}) as flow: + flow.validate_actions() + flow.pass_actions() + + simple_action._post_action.assert_called_once() + self.assertFalse(os.path.exists("actions.json")) + + def test_actions_json_not_removed_on_fail(self): + simple_action = SimpleAction() + simple_action._post_action = mock.Mock(return_value=action.ActionResult(action.ActionState.FAILED)) + with FinishActionsFlowForTests({"test_one_simple_action": [simple_action]}) as flow: + flow.validate_actions() + flow.pass_actions() + + simple_action._post_action.assert_called_once() + self.assertTrue(os.path.exists("actions.json")) + class RevertActionsFlowForTests(action.RevertActionsFlow): def __init__(self, stages):