Skip to content

Commit ee07c38

Browse files
committed
[core] Propagate task result to parent taskRole
1 parent 005264e commit ee07c38

1 file changed

Lines changed: 23 additions & 2 deletions

File tree

core/scheduler.go

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ import (
3333
"errors"
3434
"fmt"
3535
"github.com/AliceO2Group/Control/common/controlmode"
36+
"github.com/AliceO2Group/Control/common/utils"
37+
"github.com/AliceO2Group/Control/core/workflow"
3638
"github.com/spf13/viper"
3739
"io"
3840
"strconv"
@@ -348,10 +350,29 @@ func handleDeviceEvent(state *internalState, evt event.DeviceEvent) {
348350
"finalMesosState": btt.FinalMesosState.String(),
349351
}).
350352
Info("basic task terminated")
353+
354+
// Propagate this information to the task/role
355+
taskId := evt.GetOrigin().TaskId
356+
t := state.taskman.GetTask(taskId.Value)
357+
if t != nil {
358+
if parentRole, ok := t.GetParentRole().(workflow.Role); ok {
359+
parentRole.SetRuntimeVars(map[string]string{
360+
"taskResult.exitCode": strconv.Itoa(btt.ExitCode),
361+
"taskResult.stdout": btt.Stdout,
362+
"taskResult.stderr": btt.Stderr,
363+
"taskResult.finalStatus": btt.FinalMesosState.String(),
364+
"taskResult.timestamp": utils.NewUnixTimestamp(),
365+
})
366+
} else {
367+
log.WithPrefix("scheduler").Error("DeviceEvent BASIC_TASK_TERMINATED received for task with no parent role")
368+
}
369+
} else {
370+
log.WithPrefix("scheduler").Error("cannot find task for DeviceEvent BASIC_TASK_TERMINATED")
371+
}
372+
351373
if btt.VoluntaryTermination {
352374
goto doFallthrough
353375
}
354-
// FIXME: handle propagation of exit code, final state, std{err,out}
355376
}
356377
return
357378
doFallthrough:
@@ -360,7 +381,7 @@ func handleDeviceEvent(state *internalState, evt event.DeviceEvent) {
360381
taskId := evt.GetOrigin().TaskId
361382
t := state.taskman.GetTask(taskId.Value)
362383
if t == nil {
363-
log.WithPrefix("scheduler").Error("cannot find task for DeviceEvent")
384+
log.WithPrefix("scheduler").Error("cannot find task for DeviceEvent END_OF_STREAM")
364385
return
365386
}
366387
env, err := state.environments.Environment(t.GetEnvironmentId().UUID())

0 commit comments

Comments
 (0)