From 8d2d97721a4144915892efcc2cfbc95d6aa8de35 Mon Sep 17 00:00:00 2001 From: Christian Weichel Date: Thu, 16 Sep 2021 08:54:56 +0000 Subject: [PATCH] [supervisor] Add last task output to failure message --- components/supervisor/pkg/supervisor/tasks.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/supervisor/pkg/supervisor/tasks.go b/components/supervisor/pkg/supervisor/tasks.go index c1958fb1bbc616..a7a6c6f77f457b 100644 --- a/components/supervisor/pkg/supervisor/tasks.go +++ b/components/supervisor/pkg/supervisor/tasks.go @@ -68,6 +68,7 @@ type task struct { command string successChan chan taskSuccess title string + lastOutput string } type headlessTaskProgressReporter interface { @@ -299,7 +300,7 @@ func (tm *tasksManager) Run(ctx context.Context, wg *sync.WaitGroup, successChan msg = err.Error() } - t.successChan <- taskFailed(msg) + t.successChan <- taskFailed(fmt.Sprintf("%s: %s", msg, t.lastOutput)) } taskLog.Info("task terminal has been closed") tm.setTaskState(t, api.TaskState_closed) @@ -317,7 +318,6 @@ func (tm *tasksManager) Run(ctx context.Context, wg *sync.WaitGroup, successChan select { case <-ctx.Done(): success = taskFailed(ctx.Err().Error()) - break case taskResult := <-task.successChan: if taskResult.Failed() { success = success.Fail(string(taskResult)) @@ -478,6 +478,7 @@ func (tm *tasksManager) watch(task *task, terminal *terminal.Term) { data := string(buf[:n]) fileWriter.Write(buf[:n]) if tm.reporter != nil { + task.lastOutput = string(buf[:n]) tm.reporter.write(data, task, terminal) } }