From 77d5254e4501185677842c7b038d569934b755ec Mon Sep 17 00:00:00 2001 From: Piotr Konopka Date: Tue, 14 Oct 2025 16:04:18 +0200 Subject: [PATCH] OCTRL-1049 Stop tasks within GO_ERROR transition This moves stopping RUNNING tasks into GO_ERROR transition, so that the stop order makes sense - FLP and EPN tasks stop roughly in parallel. Before, FLP tasks would be stopped only after EPN tasks, which was preventing EPNs to finalize certain computations and was generally opposite to the data flow. I could not see any unwanted side effects of this change, seemed good on staging. --- core/environment/environment.go | 16 ---------------- core/environment/transition_goerror.go | 22 ++++++++++++++++++++-- 2 files changed, 20 insertions(+), 18 deletions(-) diff --git a/core/environment/environment.go b/core/environment/environment.go index 3c8bfe99c..f5c8b70b7 100644 --- a/core/environment/environment.go +++ b/core/environment/environment.go @@ -1236,22 +1236,6 @@ func (env *Environment) subscribeToWfState(taskman *task.Manager) { env.setState(wfState.String()) } } - toStop := env.Workflow().GetTasks().Filtered(func(t *task.Task) bool { - t.SetSafeToStop(true) - return t.IsSafeToStop() - }) - if len(toStop) > 0 { - taskmanMessage := task.NewTransitionTaskMessage( - toStop, - sm.RUNNING.String(), - sm.STOP.String(), - sm.CONFIGURED.String(), - nil, - env.Id(), - ) - taskman.MessageChannel <- taskmanMessage - <-env.stateChangedCh - } }) break WORKFLOW_STATE_LOOP } diff --git a/core/environment/transition_goerror.go b/core/environment/transition_goerror.go index f8f5467df..6b59d85f7 100644 --- a/core/environment/transition_goerror.go +++ b/core/environment/transition_goerror.go @@ -26,6 +26,7 @@ package environment import ( "github.com/AliceO2Group/Control/core/task" + "github.com/AliceO2Group/Control/core/task/sm" ) func NewGoErrorTransition(taskman *task.Manager) Transition { @@ -42,7 +43,24 @@ type GoErrorTransition struct { } func (t GoErrorTransition) do(env *Environment) (err error) { - // We do not do anything here, because the error handling was already implemented elsewhere - // and we do not expose this transition to external calls (e.g. from the GUI). + + // we stop all tasks which are in RUNNING + toStop := env.Workflow().GetTasks().Filtered(func(t *task.Task) bool { + t.SetSafeToStop(true) + return t.IsSafeToStop() + }) + if len(toStop) > 0 { + taskmanMessage := task.NewTransitionTaskMessage( + toStop, + sm.RUNNING.String(), + sm.STOP.String(), + sm.CONFIGURED.String(), + nil, + env.Id(), + ) + t.taskman.MessageChannel <- taskmanMessage + <-env.stateChangedCh + } + return }