Skip to content

Commit

Permalink
cr feedback (to be squashed)
Browse files Browse the repository at this point in the history
  • Loading branch information
petderek committed Feb 22, 2019
1 parent c9f8c0f commit 85397fb
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions agent/engine/task_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}{}
Expand All @@ -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())
}
Expand Down

0 comments on commit 85397fb

Please sign in to comment.