Always return an IP address (#2065)

This commit is contained in:
Manuel Alejandro de Brito Fontes 2018-02-11 12:39:01 -08:00 committed by GitHub
parent 42c7111259
commit d4784cfe59
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -45,25 +45,29 @@ func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP
return "" return ""
} }
ip := ""
for _, address := range node.Status.Addresses {
if address.Type == apiv1.NodeExternalIP {
if address.Address != "" {
ip = address.Address
break
}
}
}
if useInternalIP { if useInternalIP {
for _, address := range node.Status.Addresses { for _, address := range node.Status.Addresses {
if address.Type == apiv1.NodeInternalIP { if address.Type == apiv1.NodeInternalIP {
if address.Address != "" { if address.Address != "" {
return address.Address ip = address.Address
} break
}
}
} else {
for _, address := range node.Status.Addresses {
if address.Type == apiv1.NodeExternalIP {
if address.Address != "" {
return address.Address
} }
} }
} }
} }
return "" return ip
} }
// PodInfo contains runtime information about the pod running the Ingres controller // PodInfo contains runtime information about the pod running the Ingres controller