Fix workers immediately switching state on a lazy request
Fix an issue where workers would switch immediately on a state change request, even if it was of the "after task is finished" kind. The "may I keep running" endpoint wasn't checking the lazyness flag, and thus any state change, lazy or otherwise, would interrupt the worker's current task.
This commit is contained in:
parent
ad0fea241d
commit
e77bd9b841
@ -7,6 +7,7 @@ bugs in actually-released versions.
|
||||
## 3.2 - in development
|
||||
|
||||
- When rendering EXR files, use Blender's preview JPEG files to generate the preview video ([43bc22f10fae](https://developer.blender.org/rF43bc22f10fae0fcaed6a4a3b3ace1be617193e21)).
|
||||
- Fix issue where workers would switch immediately on a state change request, even if it was of the "after task is finished" kind.
|
||||
|
||||
|
||||
## 3.1 - released 2022-10-18
|
||||
|
@ -550,7 +550,7 @@ func (f *Flamenco) MayWorkerRun(e echo.Context, taskID string) error {
|
||||
|
||||
// mayWorkerRun checks the worker and the task, to see if this worker may keep running this task.
|
||||
func mayWorkerRun(worker *persistence.Worker, dbTask *persistence.Task) api.MayKeepRunning {
|
||||
if worker.StatusRequested != "" {
|
||||
if worker.StatusRequested != "" && !worker.LazyStatusRequest {
|
||||
return api.MayKeepRunning{
|
||||
Reason: "worker status change requested",
|
||||
StatusChangeRequested: true,
|
||||
|
@ -465,7 +465,7 @@ func TestMayWorkerRun(t *testing.T) {
|
||||
// Expect the worker to be marked as 'seen' regardless of whether it may run
|
||||
// its current task or not, so equal to the number of calls to
|
||||
// `MayWorkerRun()` below.
|
||||
mf.persistence.EXPECT().WorkerSeen(gomock.Any(), &worker).Times(4)
|
||||
mf.persistence.EXPECT().WorkerSeen(gomock.Any(), &worker).Times(5)
|
||||
|
||||
// Test: unhappy, task unassigned
|
||||
{
|
||||
@ -519,6 +519,22 @@ func TestMayWorkerRun(t *testing.T) {
|
||||
StatusChangeRequested: true,
|
||||
})
|
||||
}
|
||||
|
||||
// Test: happy, assigned and runnable; worker should go to bed after task is finished.
|
||||
{
|
||||
// Expect a 'touch' of the task.
|
||||
mf.persistence.EXPECT().TaskTouchedByWorker(gomock.Any(), &task).Return(nil)
|
||||
|
||||
worker.StatusChangeRequest(api.WorkerStatusAsleep, true)
|
||||
echo := prepareRequest()
|
||||
task.WorkerID = &worker.ID
|
||||
task.Status = api.TaskStatusActive
|
||||
err := mf.flamenco.MayWorkerRun(echo, task.UUID)
|
||||
assert.NoError(t, err)
|
||||
assertResponseJSON(t, echo, http.StatusOK, api.MayKeepRunning{
|
||||
MayKeepRunning: true,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func TestTaskOutputProduced(t *testing.T) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user