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.
This commit is contained in:
Andy Goldstein 2016-08-22 15:55:42 -04:00
parent b8990593f2
commit 8530ede61f

View File

@ -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