Skip to content

Commit

Permalink
[supervisor] Add last task output to failure message
Browse files Browse the repository at this point in the history
  • Loading branch information
csweichel committed Sep 16, 2021
1 parent 8b8fdc6 commit 1337d47
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions components/supervisor/pkg/supervisor/tasks.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ type task struct {
command string
successChan chan taskSuccess
title string
lastOutput string
}

type headlessTaskProgressReporter interface {
Expand Down Expand Up @@ -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)
Expand All @@ -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))
Expand Down Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 1337d47

Please sign in to comment.