From 6728c52055ba639312a293306cf58ce4be5d2aa6 Mon Sep 17 00:00:00 2001 From: Aaron Lehmann Date: Fri, 14 Jul 2017 12:15:35 -0700 Subject: [PATCH] orchestrator/update: Only shut down old tasks on success In start-then-stop mode, the updater waits for a verdict on the startup of a new task, and then shuts down the tasks that this new task was meant to replace. It should really only shut down the old task if the new task successfully reached running. The thinking here was probably that a task which fails on startup would briefly enter the running state before failing, so there isn't much point in distinguishing between running and some terminal state. However, if a health check is being used, the task may never enter the running state. This can also happen when a task is rejected by a node. Signed-off-by: Aaron Lehmann --- manager/orchestrator/update/updater.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manager/orchestrator/update/updater.go b/manager/orchestrator/update/updater.go index 2b1f55d3f2..8ba417c780 100644 --- a/manager/orchestrator/update/updater.go +++ b/manager/orchestrator/update/updater.go @@ -430,7 +430,7 @@ func (u *Updater) updateTask(ctx context.Context, slot orchestrator.Slot, update u.updatedTasks[updated.ID] = time.Now() u.updatedTasksMu.Unlock() - if startThenStop { + if startThenStop && updated.Status.State == api.TaskStateRunning { err := u.store.Batch(func(batch *store.Batch) error { _, err := u.removeOldTasks(ctx, batch, slot) if err != nil {