From 30cf0f9890b30f64f5bb78e1ac2c439f560b4288 Mon Sep 17 00:00:00 2001 From: Fabiano Franz Date: Tue, 2 Aug 2016 19:11:52 -0300 Subject: [PATCH] Handle container terminated but pod still running in conditions --- pkg/client/unversioned/conditions.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/client/unversioned/conditions.go b/pkg/client/unversioned/conditions.go index 5c284292bff..62dcdf6428e 100644 --- a/pkg/client/unversioned/conditions.go +++ b/pkg/client/unversioned/conditions.go @@ -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