executor: fix reporting of stopped tasks and steps

In executeTask set the executor task and step phase to stop if task spec Stop is
true.
This commit is contained in:
Simone Gotti 2020-02-27 11:57:00 +01:00
parent 268a2b83ea
commit 19b8c7f427
1 changed files with 10 additions and 2 deletions

View File

@ -822,7 +822,11 @@ func (e *Executor) executeTask(ctx context.Context, et *types.ExecutorTask) {
rt.Lock() rt.Lock()
if err != nil { if err != nil {
log.Errorf("err: %+v", err) log.Errorf("err: %+v", err)
et.Status.Phase = types.ExecutorTaskPhaseFailed if rt.et.Spec.Stop {
et.Status.Phase = types.ExecutorTaskPhaseStopped
} else {
et.Status.Phase = types.ExecutorTaskPhaseFailed
}
} else { } else {
et.Status.Phase = types.ExecutorTaskPhaseSuccess et.Status.Phase = types.ExecutorTaskPhaseSuccess
} }
@ -997,7 +1001,11 @@ func (e *Executor) executeTaskSteps(ctx context.Context, rt *runningTask, pod dr
} }
serr = errors.Errorf("failed to execute step %s: %w", util.Dump(step), err) serr = errors.Errorf("failed to execute step %s: %w", util.Dump(step), err)
} else if exitCode != 0 { } else if exitCode != 0 {
rt.et.Status.Steps[i].Phase = types.ExecutorTaskPhaseFailed if rt.et.Spec.Stop {
rt.et.Status.Steps[i].Phase = types.ExecutorTaskPhaseStopped
} else {
rt.et.Status.Steps[i].Phase = types.ExecutorTaskPhaseFailed
}
rt.et.Status.Steps[i].ExitStatus = util.IntP(exitCode) rt.et.Status.Steps[i].ExitStatus = util.IntP(exitCode)
serr = errors.Errorf("step %q failed with exitcode %d", stepName, exitCode) serr = errors.Errorf("step %q failed with exitcode %d", stepName, exitCode)
} else if exitCode == 0 { } else if exitCode == 0 {