Handle container terminated but pod still running in conditions

This commit is contained in:
Fabiano Franz
2016-08-02 19:11:52 -03:00
parent f2a9ba2339
commit 30cf0f9890

View File

@@ -121,6 +121,10 @@ func DeploymentHasDesiredReplicas(c ExtensionsInterface, deployment *extensions.
// the pod has already reached completed state.
var ErrPodCompleted = fmt.Errorf("pod ran to completion")
// ErrContainerTerminated is returned by PodContainerRunning in the intermediate
// state where the pod indicates it's still running, but its container is already terminated
var ErrContainerTerminated = fmt.Errorf("container terminated")
// PodRunning returns true if the pod is running, false if the pod has not yet reached running state,
// returns ErrPodCompleted if the pod has run to completion, or an error in any other case.
func PodRunning(event watch.Event) (bool, error) {
@@ -217,6 +221,9 @@ func PodContainerRunning(containerName string) watch.ConditionFunc {
if s.Name != containerName {
continue
}
if s.State.Terminated != nil {
return false, ErrContainerTerminated
}
return s.State.Running != nil, nil
}
return false, nil