Check pod container ready state (#861)

Ensure pod is ready by checking pod’s containers state and deletionTimestamp
This commit is contained in:
Ta-Ching Chen
2018-09-07 22:17:07 +08:00
committed by GitHub
parent 2dbae32f20
commit a4f58fbf10
2 changed files with 11 additions and 14 deletions
+8 -1
View File
@@ -108,13 +108,20 @@ func IsNetworkDialError(err error) bool {
return false
}
// IsReadyPod checks that all containers in a pod are ready and returns true if so
// IsReadyPod checks both all containers in a pod are ready and whether
// the .metadata.DeletionTimestamp is nil.
func IsReadyPod(pod *apiv1.Pod) bool {
// since its a utility function, just ensuring there is no nil pointer exception
if pod == nil {
return false
}
// pod is in "Terminating" status if deletionTimestamp is not nil
// https://github.com/kubernetes/kubernetes/issues/61376
if pod.ObjectMeta.DeletionTimestamp != nil {
return false
}
for _, cStatus := range pod.Status.ContainerStatuses {
if !cStatus.Ready {
return false