Skip to content

Commit a0fef46

Browse files
authored
OCTRL-1049 Stop tasks within GO_ERROR transition (#756)
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.
1 parent c7ee461 commit a0fef46

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

core/environment/environment.go

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,22 +1236,6 @@ func (env *Environment) subscribeToWfState(taskman *task.Manager) {
12361236
env.setState(wfState.String())
12371237
}
12381238
}
1239-
toStop := env.Workflow().GetTasks().Filtered(func(t *task.Task) bool {
1240-
t.SetSafeToStop(true)
1241-
return t.IsSafeToStop()
1242-
})
1243-
if len(toStop) > 0 {
1244-
taskmanMessage := task.NewTransitionTaskMessage(
1245-
toStop,
1246-
sm.RUNNING.String(),
1247-
sm.STOP.String(),
1248-
sm.CONFIGURED.String(),
1249-
nil,
1250-
env.Id(),
1251-
)
1252-
taskman.MessageChannel <- taskmanMessage
1253-
<-env.stateChangedCh
1254-
}
12551239
})
12561240
break WORKFLOW_STATE_LOOP
12571241
}

core/environment/transition_goerror.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ package environment
2626

2727
import (
2828
"github.com/AliceO2Group/Control/core/task"
29+
"github.com/AliceO2Group/Control/core/task/sm"
2930
)
3031

3132
func NewGoErrorTransition(taskman *task.Manager) Transition {
@@ -42,7 +43,24 @@ type GoErrorTransition struct {
4243
}
4344

4445
func (t GoErrorTransition) do(env *Environment) (err error) {
45-
// We do not do anything here, because the error handling was already implemented elsewhere
46-
// and we do not expose this transition to external calls (e.g. from the GUI).
46+
47+
// we stop all tasks which are in RUNNING
48+
toStop := env.Workflow().GetTasks().Filtered(func(t *task.Task) bool {
49+
t.SetSafeToStop(true)
50+
return t.IsSafeToStop()
51+
})
52+
if len(toStop) > 0 {
53+
taskmanMessage := task.NewTransitionTaskMessage(
54+
toStop,
55+
sm.RUNNING.String(),
56+
sm.STOP.String(),
57+
sm.CONFIGURED.String(),
58+
nil,
59+
env.Id(),
60+
)
61+
t.taskman.MessageChannel <- taskmanMessage
62+
<-env.stateChangedCh
63+
}
64+
4765
return
4866
}

0 commit comments

Comments
 (0)