From 18524065e8cb1e33ec2c066cff930541830026a3 Mon Sep 17 00:00:00 2001 From: Anshul Pundir Date: Fri, 22 Jun 2018 14:49:33 -0700 Subject: [PATCH] sda --- manager/orchestrator/taskreaper/task_reaper.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/manager/orchestrator/taskreaper/task_reaper.go b/manager/orchestrator/taskreaper/task_reaper.go index 3bdd8b4220..bd39017022 100644 --- a/manager/orchestrator/taskreaper/task_reaper.go +++ b/manager/orchestrator/taskreaper/task_reaper.go @@ -176,6 +176,17 @@ func (tr *TaskReaper) tick() { defer func() { tr.cleanup = nil + + // Clean out the dirty set at the end of this tick iteration. + // When tick() finishes, the tasks in the slot were either cleaned up, + // or it was skipped because it didn't meet the criteria for cleaning. + // Either way, we can discard the dirty set because future events on that slot + // will cause the task to be readded to the dirty set at that point. + // + // TODO(anshul) The only edge case is when there are more than one running tasks present + // for a given slot. In that case, the slot may remain uncleaned until there is a task + // restart for that slot. + tr.dirty = nil }() deleteTasks := make(map[string]struct{}) @@ -188,9 +199,6 @@ func (tr *TaskReaper) tick() { for dirty := range tr.dirty { service := store.GetService(tx, dirty.ServiceID) if service == nil { - // If the service can't be found, assume that it was deleted - // and remove the slot from the dirty list. - delete(tr.dirty, dirty) continue } @@ -272,10 +280,6 @@ func (tr *TaskReaper) tick() { break } } - - if runningTasks <= 1 { - delete(tr.dirty, dirty) - } } })