From 4965ffcb1cca214767a5b5aaa0ff03061198857e Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Tue, 2 Aug 2016 09:39:42 -0700 Subject: [PATCH] dispatcher: Always send task updates to agent when state <= ASSIGNED The use of TaskEqualStable in the dispatcher to avoid sending unnecessary task updates is problematic for global services. These tasks only move to the ASSIGNED state once the scheduler confirms resources are available. Since state changes are not considered relevant changes and do not trigger assignment set updates, the dispatcher may never send this update, and tasks can become stuck in the ASSIGNED state. If a task is in the state ASSIGNED or below, always count a state change as a modification, even if nothing else has changed. Signed-off-by: Aaron Lehmann --- manager/dispatcher/dispatcher.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/manager/dispatcher/dispatcher.go b/manager/dispatcher/dispatcher.go index a0d984f9fe..6b1c0f8438 100644 --- a/manager/dispatcher/dispatcher.go +++ b/manager/dispatcher/dispatcher.go @@ -595,7 +595,10 @@ func (d *Dispatcher) Tasks(r *api.TasksRequest, stream api.Dispatcher_TasksServe modificationCnt++ case state.EventUpdateTask: if oldTask, exists := tasksMap[v.Task.ID]; exists { - if equality.TasksEqualStable(oldTask, v.Task) { + // States ASSIGNED and below are set by the orchestrator/scheduler, + // not the agent, so tasks in these states need to be sent to the + // agent even if nothing else has changed. + if equality.TasksEqualStable(oldTask, v.Task) && v.Task.Status.State > api.TaskStateAssigned { // this update should not trigger action at agent tasksMap[v.Task.ID] = v.Task continue