Only pods in running phase are vallid for status

This commit is contained in:
Manuel de Brito Fontes 2018-02-15 01:21:17 -03:00
parent 1f79333789
commit 29e3605b78
No known key found for this signature in database
GPG key ID: 786136016A8BA02A
2 changed files with 23 additions and 0 deletions

View file

@ -260,6 +260,11 @@ func (s *statusSync) runningAddresses() ([]string, error) {
}
for _, pod := range pods.Items {
// only Running pods are valid
if pod.Status.Phase != apiv1.PodRunning {
continue
}
name := k8s.GetNodeIPOrName(s.Client, pod.Spec.NodeName, s.UseNodeInternalIP)
if !sliceutils.StringInSlice(name, addrs) {
addrs = append(addrs, name)

View file

@ -66,6 +66,21 @@ func buildSimpleClientSet() *testclient.Clientset {
Spec: apiv1.PodSpec{
NodeName: "foo_node_2",
},
Status: apiv1.PodStatus{
Phase: apiv1.PodRunning,
},
},
{
ObjectMeta: metav1.ObjectMeta{
Name: "foo1-unknown",
Namespace: apiv1.NamespaceDefault,
},
Spec: apiv1.PodSpec{
NodeName: "foo_node_1",
},
Status: apiv1.PodStatus{
Phase: apiv1.PodUnknown,
},
},
{
ObjectMeta: metav1.ObjectMeta{
@ -87,6 +102,9 @@ func buildSimpleClientSet() *testclient.Clientset {
Spec: apiv1.PodSpec{
NodeName: "foo_node_2",
},
Status: apiv1.PodStatus{
Phase: apiv1.PodRunning,
},
},
}},
&apiv1.ServiceList{Items: []apiv1.Service{