Skip to content

Commit 8d2d977

Browse files
csweichelroboquat
authored andcommitted
[supervisor] Add last task output to failure message
1 parent 64f69a4 commit 8d2d977

File tree

1 file changed

+3
-2
lines changed
  • components/supervisor/pkg/supervisor

1 file changed

+3
-2
lines changed

components/supervisor/pkg/supervisor/tasks.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ type task struct {
6868
command string
6969
successChan chan taskSuccess
7070
title string
71+
lastOutput string
7172
}
7273

7374
type headlessTaskProgressReporter interface {
@@ -299,7 +300,7 @@ func (tm *tasksManager) Run(ctx context.Context, wg *sync.WaitGroup, successChan
299300
msg = err.Error()
300301
}
301302

302-
t.successChan <- taskFailed(msg)
303+
t.successChan <- taskFailed(fmt.Sprintf("%s: %s", msg, t.lastOutput))
303304
}
304305
taskLog.Info("task terminal has been closed")
305306
tm.setTaskState(t, api.TaskState_closed)
@@ -317,7 +318,6 @@ func (tm *tasksManager) Run(ctx context.Context, wg *sync.WaitGroup, successChan
317318
select {
318319
case <-ctx.Done():
319320
success = taskFailed(ctx.Err().Error())
320-
break
321321
case taskResult := <-task.successChan:
322322
if taskResult.Failed() {
323323
success = success.Fail(string(taskResult))
@@ -478,6 +478,7 @@ func (tm *tasksManager) watch(task *task, terminal *terminal.Term) {
478478
data := string(buf[:n])
479479
fileWriter.Write(buf[:n])
480480
if tm.reporter != nil {
481+
task.lastOutput = string(buf[:n])
481482
tm.reporter.write(data, task, terminal)
482483
}
483484
}

0 commit comments

Comments
 (0)