From 1337d47122ef41903deac7949c00187ba54ec81c 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 c2dc6ab06134c1..7c1efcae7972da 100644 --- a/components/supervisor/pkg/supervisor/tasks.go +++ b/components/supervisor/pkg/supervisor/tasks.go @@ -67,6 +67,7 @@ type task struct { command string successChan chan taskSuccess title string + lastOutput string } type headlessTaskProgressReporter interface { @@ -290,7 +291,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) @@ -308,7 +309,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)) @@ -469,6 +469,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) } }