Check pod is ready
This commit is contained in:
parent
d74ea25df8
commit
a762d8a4e3
2 changed files with 26 additions and 0 deletions
|
@ -193,6 +193,20 @@ func (s *statusSync) runningAddresses() ([]string, error) {
|
|||
continue
|
||||
}
|
||||
|
||||
// only Ready pods are valid
|
||||
isPodReady := false
|
||||
for _, cond := range pod.Status.Conditions {
|
||||
if cond.Type == apiv1.PodReady && cond.Status == apiv1.ConditionTrue {
|
||||
isPodReady = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
if !isPodReady {
|
||||
klog.InfoS("POD is not ready", "pod", klog.KObj(&pod), "node", pod.Spec.NodeName)
|
||||
continue
|
||||
}
|
||||
|
||||
name := k8s.GetNodeIPOrName(s.Client, pod.Spec.NodeName, s.UseNodeInternalIP)
|
||||
if !sliceutils.StringInSlice(name, addrs) {
|
||||
addrs = append(addrs, name)
|
||||
|
|
|
@ -72,6 +72,12 @@ func buildSimpleClientSet() *testclient.Clientset {
|
|||
},
|
||||
Status: apiv1.PodStatus{
|
||||
Phase: apiv1.PodRunning,
|
||||
Conditions: []apiv1.PodCondition{
|
||||
{
|
||||
Type: apiv1.PodReady,
|
||||
Status: apiv1.ConditionTrue,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -108,6 +114,12 @@ func buildSimpleClientSet() *testclient.Clientset {
|
|||
},
|
||||
Status: apiv1.PodStatus{
|
||||
Phase: apiv1.PodRunning,
|
||||
Conditions: []apiv1.PodCondition{
|
||||
{
|
||||
Type: apiv1.PodReady,
|
||||
Status: apiv1.ConditionTrue,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
}},
|
||||
|
|
Loading…
Reference in a new issue