Check pod container ready state (#861)
Ensure pod is ready by checking pod’s containers state and deletionTimestamp
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user