Consider Pod Phase in IsReadyPod (#1080)
This commit is contained in:
committed by
Ta-Ching Chen
parent
6893403ba7
commit
1806259637
@@ -120,12 +120,26 @@ func IsReadyPod(pod *apiv1.Pod) bool {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pod is not in Running Phase. It can be in Pending,
|
||||||
|
// Succeeded, Failed, Unknown. In some cases the pod can be in
|
||||||
|
// different sate than Running, for example Kubernetes sets a
|
||||||
|
// pod to Termination while k8s waits for the grace period of
|
||||||
|
// the pod, even if all the containers are in Ready state.
|
||||||
|
if pod.Status.Phase != apiv1.PodRunning {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
// pod is in "Terminating" status if deletionTimestamp is not nil
|
// pod is in "Terminating" status if deletionTimestamp is not nil
|
||||||
// https://github.com/kubernetes/kubernetes/issues/61376
|
// https://github.com/kubernetes/kubernetes/issues/61376
|
||||||
if pod.ObjectMeta.DeletionTimestamp != nil {
|
if pod.ObjectMeta.DeletionTimestamp != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// pod does not have an IP address allocated to it yet
|
||||||
|
if pod.Status.PodIP == "" {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
for _, cStatus := range pod.Status.ContainerStatuses {
|
for _, cStatus := range pod.Status.ContainerStatuses {
|
||||||
if !cStatus.Ready {
|
if !cStatus.Ready {
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -305,7 +305,7 @@ func (gp *GenericPool) specializePod(pod *apiv1.Pod, metadata *metav1.ObjectMeta
|
|||||||
// for fetcher we don't need to create a service, just talk to the pod directly
|
// for fetcher we don't need to create a service, just talk to the pod directly
|
||||||
podIP := pod.Status.PodIP
|
podIP := pod.Status.PodIP
|
||||||
if len(podIP) == 0 {
|
if len(podIP) == 0 {
|
||||||
return errors.New("Pod has no IP")
|
return errors.Errorf("Pod %s in namespace %s has no IP", pod.ObjectMeta.Name, pod.ObjectMeta.Namespace)
|
||||||
}
|
}
|
||||||
// specialize pod with service
|
// specialize pod with service
|
||||||
if gp.useIstio {
|
if gp.useIstio {
|
||||||
|
|||||||
Reference in New Issue
Block a user