Skip to content

Commit b19438a

Browse files
committed
fix: correctly mark tasks as inprogress before execution
1 parent f1cc661 commit b19438a

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

internal/orchestrator/tasks.go

+3-4
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ func (t *TaskWithOperation) Cancel(withStatus v1.OperationStatus) error {
8484
// timestamps are automatically added and the status is automatically updated if an error occurs.
8585
func WithOperation(oplog *oplog.OpLog, op *v1.Operation, do func() error) error {
8686
op.UnixTimeStartMs = curTimeMillis() // update the start time from the planned time to the actual time.
87+
if op.Status == v1.OperationStatus_STATUS_PENDING || op.Status == v1.OperationStatus_STATUS_UNKNOWN {
88+
op.Status = v1.OperationStatus_STATUS_INPROGRESS
89+
}
8790
if op.Id != 0 {
8891
if err := oplog.Update(op); err != nil {
8992
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
9396
return fmt.Errorf("failed to add operation to oplog: %w", err)
9497
}
9598
}
96-
97-
if op.Status == v1.OperationStatus_STATUS_PENDING || op.Status == v1.OperationStatus_STATUS_UNKNOWN {
98-
op.Status = v1.OperationStatus_STATUS_INPROGRESS
99-
}
10099
err := do()
101100
if err != nil {
102101
op.Status = v1.OperationStatus_STATUS_ERROR

0 commit comments

Comments
 (0)