From 81ffb510e95c7862dd2a02880b4ba238bf58ad80 Mon Sep 17 00:00:00 2001 From: garethgeorge Date: Thu, 4 Jan 2024 18:12:50 -0800 Subject: [PATCH] fix: correctly mark tasks as inprogress before execution --- internal/orchestrator/tasks.go | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/internal/orchestrator/tasks.go b/internal/orchestrator/tasks.go index 8c3e420d..7dd3b298 100644 --- a/internal/orchestrator/tasks.go +++ b/internal/orchestrator/tasks.go @@ -84,6 +84,9 @@ func (t *TaskWithOperation) Cancel(withStatus v1.OperationStatus) error { // timestamps are automatically added and the status is automatically updated if an error occurs. func WithOperation(oplog *oplog.OpLog, op *v1.Operation, do func() error) error { op.UnixTimeStartMs = curTimeMillis() // update the start time from the planned time to the actual time. + if op.Status == v1.OperationStatus_STATUS_PENDING || op.Status == v1.OperationStatus_STATUS_UNKNOWN { + op.Status = v1.OperationStatus_STATUS_INPROGRESS + } if op.Id != 0 { if err := oplog.Update(op); err != nil { return fmt.Errorf("failed to add operation to oplog: %w", err) @@ -93,10 +96,6 @@ func WithOperation(oplog *oplog.OpLog, op *v1.Operation, do func() error) error return fmt.Errorf("failed to add operation to oplog: %w", err) } } - - if op.Status == v1.OperationStatus_STATUS_PENDING || op.Status == v1.OperationStatus_STATUS_UNKNOWN { - op.Status = v1.OperationStatus_STATUS_INPROGRESS - } err := do() if err != nil { op.Status = v1.OperationStatus_STATUS_ERROR