From 85397fb35dc3d4aa92edec5e0cc68f1283ed13fa Mon Sep 17 00:00:00 2001 From: Derek Petersen Date: Thu, 21 Feb 2019 17:36:25 -0800 Subject: [PATCH] cr feedback (to be squashed) --- agent/engine/task_manager.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/agent/engine/task_manager.go b/agent/engine/task_manager.go index 32e84603de0..bfcf50b6020 100644 --- a/agent/engine/task_manager.go +++ b/agent/engine/task_manager.go @@ -742,7 +742,7 @@ func (mtask *managedTask) progressTask() { transitionChangeEntity <- resource.GetName() }) - anyContainerTransition, blockedTransitions, contTransitions, reasons := mtask.startContainerTransitions( + anyContainerTransition, blockedDependencies, contTransitions, reasons := mtask.startContainerTransitions( func(container *apicontainer.Container, nextStatus apicontainerstatus.ContainerStatus) { mtask.engine.transitionContainer(mtask.Task, container, nextStatus) transitionChange <- struct{}{} @@ -751,20 +751,25 @@ func (mtask *managedTask) progressTask() { atLeastOneTransitionStarted := anyResourceTransition || anyContainerTransition - if !atLeastOneTransitionStarted && len(blockedTransitions) == 0 { + blockedByOrderingDependencies := len(blockedDependencies) > 0 + + // If no transitions happened and we aren't blocked by ordering dependencies, then we are possibly in a state where + // its impossible for containers to move forward. We will do an additional check to see if we are waiting for ACS + // execution credentials. If not, then we will abort the task progression. + if !atLeastOneTransitionStarted && !blockedByOrderingDependencies { if !mtask.isWaitingForACSExecutionCredentials(reasons) { mtask.handleContainersUnableToTransitionState() } return } - // If no containers are starting and we are blocked on dependency conditions, we should watch for the task to change + // If no containers are starting and we are blocked on ordering dependencies, we should watch for the task to change // over time. This will update the containers if they become healthy or stop, which makes it possible for the // conditions "HEALTHY" and "SUCCESS" to succeed. - if !atLeastOneTransitionStarted && len(blockedTransitions) > 0 { + if !atLeastOneTransitionStarted && blockedByOrderingDependencies { go mtask.engine.checkTaskState(mtask.Task) - ctx, cl := context.WithTimeout(context.Background(), transitionPollTime) - defer cl() + ctx, cancel := context.WithTimeout(context.Background(), transitionPollTime) + defer cancel() for timeout := mtask.waitEvent(ctx.Done()); !timeout; { timeout = mtask.waitEvent(ctx.Done()) }