From 20c2c8c354b0b3ae1d34795c207a2117e8604aaf Mon Sep 17 00:00:00 2001
From: Karel van Klink <karel.vanklink@geant.org>
Date: Mon, 27 Nov 2023 15:30:36 +0100
Subject: [PATCH] Add an indifferent pp interaction, that won't make the
 workflow fail despite the outcome

---
 gso/services/provisioning_proxy.py | 32 ++++++++++++++++++++++++++++++
 1 file changed, 32 insertions(+)

diff --git a/gso/services/provisioning_proxy.py b/gso/services/provisioning_proxy.py
index bd952958..f18de6c2 100644
--- a/gso/services/provisioning_proxy.py
+++ b/gso/services/provisioning_proxy.py
@@ -287,6 +287,11 @@ def _evaluate_pp_results(callback_result: dict) -> State:
     return {"callback_result": callback_result}
 
 
+@step("Ignore provisioning proxy result")
+def _ignore_pp_results(callback_result: dict) -> State:
+    return {"callback_result": callback_result}
+
+
 @inputstep("Confirm provisioning proxy results", assignee=Assignee("SYSTEM"))
 def _show_pp_results(state: State) -> FormGenerator:
     if "callback_result" not in state:
@@ -324,3 +329,30 @@ def pp_interaction(provisioning_step: Step) -> StepList:
         )
         >> _show_pp_results
     )
+
+
+def indifferent_pp_interaction(provisioning_step: Step) -> StepList:
+    """Interact with the provisioning proxy :term:`LSO` using a callback step.
+
+    This interaction is identical from the one described in ``pp_interaction()``, with one functional difference.
+    Whereas the ``pp_interaction()`` will make the workflow step fail on unsuccessful interaction, this step will not.
+    It is therefore indifferent about the outcome of the Ansible playbook that is executed.
+
+    .. warning::
+       Using this interaction requires the operator to carefully evaluate the outcome of a playbook themselves. If a
+       playbook fails, this will not cause the workflow to fail.
+
+    :param provisioning_step: A workflow step that performs an operation remotely using the provisioning proxy.
+    :type provisioning_step: :class:`Step`
+    :return: A list of steps that is executed as part of the workflow.
+    :rtype: :class:`StepList`
+    """
+    return (
+        begin
+        >> callback_step(
+            name=provisioning_step.name,
+            action_step=provisioning_step,
+            validate_step=_ignore_pp_results,
+        )
+        >> _show_pp_results
+    )
-- 
GitLab