Manager: Start timeout counting as soon as Worker gets task assigned
Set the task's "last touched" field in the database to "now" as soon as the task is assigned to a worker.
This commit is contained in:
parent
87bce6be36
commit
354fd29f9e
@ -322,6 +322,11 @@ func (f *Flamenco) ScheduleTask(e echo.Context) error {
|
|||||||
f.taskLogAppendTimestamped(logger, dbTask,
|
f.taskLogAppendTimestamped(logger, dbTask,
|
||||||
fmt.Sprintf("Task assigned to worker %s (%s)\n", worker.Name, worker.UUID))
|
fmt.Sprintf("Task assigned to worker %s (%s)\n", worker.Name, worker.UUID))
|
||||||
|
|
||||||
|
// Start timeout measurement as soon as the Worker gets the task assigned.
|
||||||
|
if err := f.workerPingedTask(e.Request().Context(), logger, dbTask); err != nil {
|
||||||
|
return sendAPIError(e, http.StatusInternalServerError, "internal error updating task for timeout calculation: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
// Convert database objects to API objects:
|
// Convert database objects to API objects:
|
||||||
apiCommands := []api.Command{}
|
apiCommands := []api.Command{}
|
||||||
for _, cmd := range dbTask.Commands {
|
for _, cmd := range dbTask.Commands {
|
||||||
|
@ -34,6 +34,7 @@ func TestTaskScheduleHappy(t *testing.T) {
|
|||||||
Job: &job,
|
Job: &job,
|
||||||
}
|
}
|
||||||
mf.persistence.EXPECT().ScheduleTask(echo.Request().Context(), &worker).Return(&task, nil)
|
mf.persistence.EXPECT().ScheduleTask(echo.Request().Context(), &worker).Return(&task, nil)
|
||||||
|
mf.persistence.EXPECT().TaskTouchedByWorker(echo.Request().Context(), &task)
|
||||||
|
|
||||||
mf.logStorage.EXPECT().Write(gomock.Any(), job.UUID, task.UUID,
|
mf.logStorage.EXPECT().Write(gomock.Any(), job.UUID, task.UUID,
|
||||||
"2022-06-09T11:14:41+02:00 Task assigned to worker дрон (e7632d62-c3b8-4af0-9e78-01752928952c)\n")
|
"2022-06-09T11:14:41+02:00 Task assigned to worker дрон (e7632d62-c3b8-4af0-9e78-01752928952c)\n")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user