in agent/engine/dependencygraph/graph.go [388:445]
func containerOrderingDependenciesIsResolved(target *apicontainer.Container,
dependsOnContainer *apicontainer.Container,
dependsOnStatus string,
cfg *config.Config) bool {
targetDesiredStatus := target.GetDesiredStatus()
targetContainerKnownStatus := target.GetKnownStatus()
dependsOnContainerKnownStatus := dependsOnContainer.GetKnownStatus()
// The 'target' container desires to be moved to 'Created' or the 'steady' state.
// Allow this only if the environment variable ECS_PULL_DEPENDENT_CONTAINERS_UPFRONT is enabled and
// known status of the `target` container state has not reached to 'Pulled' state;
if cfg.DependentContainersPullUpfront.Enabled() && targetContainerKnownStatus < apicontainerstatus.ContainerPulled {
return true
}
switch dependsOnStatus {
case createCondition:
// The 'target' container desires to be moved to 'Created' or the 'steady' state.
// Allow this only if the known status of the dependency container state is already started
// i.e it's state is any of 'Created', 'steady state' or 'Stopped'
return dependsOnContainerKnownStatus >= apicontainerstatus.ContainerCreated
case startCondition:
if targetDesiredStatus == apicontainerstatus.ContainerCreated {
// The 'target' container desires to be moved to 'Created' state.
// Allow this only if the known status of the linked container is
// 'Created' or if the dependency container is in 'steady state'
return dependsOnContainerKnownStatus == apicontainerstatus.ContainerCreated || dependsOnContainer.IsKnownSteadyState()
} else if targetDesiredStatus == target.GetSteadyStateStatus() {
// The 'target' container desires to be moved to its 'steady' state.
// Allow this only if the dependency container is in 'steady state' as well
return dependsOnContainer.IsKnownSteadyState()
}
return false
case successCondition:
// The 'target' container desires to be moved to 'Created' or the 'steady' state.
// Allow this only if the known status of the dependency container state is stopped with an exit code of 0
if dependsOnContainer.GetKnownExitCode() != nil {
return dependsOnContainerKnownStatus == apicontainerstatus.ContainerStopped &&
*dependsOnContainer.GetKnownExitCode() == successExitCode
}
return false
case completeCondition:
// The 'target' container desires to be moved to 'Created' or the 'steady' state.
// Allow this only if the known status of the dependency container state is stopped with any exit code
return dependsOnContainerKnownStatus == apicontainerstatus.ContainerStopped && dependsOnContainer.GetKnownExitCode() != nil
case healthyCondition:
return dependsOnContainer.HealthStatusShouldBeReported() &&
dependsOnContainer.GetHealthStatus().Status == apicontainerstatus.ContainerHealthy
default:
return false
}
}