From 1586c37b322a30fdf0a279f45cd6579b2484982c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 20 Jun 2022 13:00:41 +0200 Subject: [PATCH] Manager: mark task as active as soon as it is assigned to a worker Move the task to 'active' status so that it won't be assigned to another worker. This also enables the task timeout monitoring. --- internal/manager/api_impl/workers.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/internal/manager/api_impl/workers.go b/internal/manager/api_impl/workers.go index 329b7ade..8901721c 100644 --- a/internal/manager/api_impl/workers.go +++ b/internal/manager/api_impl/workers.go @@ -311,6 +311,12 @@ func (f *Flamenco) ScheduleTask(e echo.Context) error { return sendAPIError(e, http.StatusInternalServerError, "internal error appending to task log: %v", err) } + // Move the task to 'active' status so that it won't be assigned to another + // worker. This also enables the task timeout monitoring. + if err := f.stateMachine.TaskStatusChange(ctx, dbTask, api.TaskStatusActive); err != nil { + return sendAPIError(e, http.StatusInternalServerError, "internal error marking task as active: %v", err) + } + // Start timeout measurement as soon as the Worker gets the task assigned. if err := f.workerPingedTask(ctx, logger, dbTask); err != nil { return sendAPIError(e, http.StatusInternalServerError, "internal error updating task for timeout calculation: %v", err)