Worker: add task failures to the task log as well

Task failures were only placed in the task's activity field, and are now
added to the log as well.
This commit is contained in:
Sybren A. Stüvel 2022-06-16 12:22:05 +02:00
parent e1309ad8fc
commit 7e28cfa69c

View File

@ -81,8 +81,10 @@ func (l *Listener) TaskStarted(ctx context.Context, taskID string) error {
// TaskFailed tells the Manager the task failed for some reason. // TaskFailed tells the Manager the task failed for some reason.
func (l *Listener) TaskFailed(ctx context.Context, taskID string, reason string) error { func (l *Listener) TaskFailed(ctx context.Context, taskID string, reason string) error {
msg := fmt.Sprintf("Failed: %v", reason)
return l.sendTaskUpdate(ctx, taskID, api.TaskUpdateJSONRequestBody{ return l.sendTaskUpdate(ctx, taskID, api.TaskUpdateJSONRequestBody{
Activity: ptr(fmt.Sprintf("Failed: %v", reason)), Activity: &msg,
Log: &msg, // Make sure that this failure also ends up in the task log.
TaskStatus: ptr(api.TaskStatusFailed), TaskStatus: ptr(api.TaskStatusFailed),
}) })
} }