From 8530ede61f7774a8a871b758b276b79e6a8a5f70 Mon Sep 17 00:00:00 2001 From: Andy Goldstein Date: Mon, 22 Aug 2016 15:55:42 -0400 Subject: [PATCH] Check init containers in PodContainerRunning Sometimes when an init container runs and terminates quickly, PodContainerRunning can go into a state where the pod indicates it's still running, but the container is already terminated. Handle that condition by returning ErrContainerTerminated when it happens. --- pkg/client/unversioned/conditions.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/pkg/client/unversioned/conditions.go b/pkg/client/unversioned/conditions.go index cd913de61ac..986562e3021 100644 --- a/pkg/client/unversioned/conditions.go +++ b/pkg/client/unversioned/conditions.go @@ -238,6 +238,15 @@ func PodContainerRunning(containerName string) watch.ConditionFunc { } return s.State.Running != nil, nil } + for _, s := range t.Status.InitContainerStatuses { + if s.Name != containerName { + continue + } + if s.State.Terminated != nil { + return false, ErrContainerTerminated + } + return s.State.Running != nil, nil + } return false, nil } return false, nil