From d929885b064a0c5adfbee35d4ecfe87bcd585088 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Tue, 19 Jul 2022 17:47:43 +0200 Subject: [PATCH] Manager: only log task status change if there is an actual change Don't log "changes" from, say, `active` -> `active`. --- .../manager/task_state_machine/task_state_machine.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/internal/manager/task_state_machine/task_state_machine.go b/internal/manager/task_state_machine/task_state_machine.go index 0f7335b0..69280005 100644 --- a/internal/manager/task_state_machine/task_state_machine.go +++ b/internal/manager/task_state_machine/task_state_machine.go @@ -80,10 +80,12 @@ func (sm *StateMachine) taskStatusChangeOnly( return fmt.Errorf("saving task to database: %w", err) } - // logStorage already logs any error, and an error here shouldn't block the - // rest of the function. - _ = sm.logStorage.WriteTimestamped(logger, job.UUID, task.UUID, - fmt.Sprintf("task changed status %s -> %s", oldTaskStatus, newTaskStatus)) + if oldTaskStatus != newTaskStatus { + // logStorage already logs any error, and an error here shouldn't block the + // rest of the function. + _ = sm.logStorage.WriteTimestamped(logger, job.UUID, task.UUID, + fmt.Sprintf("task changed status %s -> %s", oldTaskStatus, newTaskStatus)) + } // Broadcast this change to the SocketIO clients. taskUpdate := webupdates.NewTaskUpdate(task)