Always return an IP address (#2065)
This commit is contained in:
parent
42c7111259
commit
d4784cfe59
1 changed files with 14 additions and 10 deletions
|
@ -45,25 +45,29 @@ func GetNodeIPOrName(kubeClient clientset.Interface, name string, useInternalIP
|
|||
return ""
|
||||
}
|
||||
|
||||
ip := ""
|
||||
|
||||
for _, address := range node.Status.Addresses {
|
||||
if address.Type == apiv1.NodeExternalIP {
|
||||
if address.Address != "" {
|
||||
ip = address.Address
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if useInternalIP {
|
||||
for _, address := range node.Status.Addresses {
|
||||
if address.Type == apiv1.NodeInternalIP {
|
||||
if address.Address != "" {
|
||||
return address.Address
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for _, address := range node.Status.Addresses {
|
||||
if address.Type == apiv1.NodeExternalIP {
|
||||
if address.Address != "" {
|
||||
return address.Address
|
||||
ip = address.Address
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ""
|
||||
return ip
|
||||
}
|
||||
|
||||
// PodInfo contains runtime information about the pod running the Ingres controller
|
||||
|
|
Loading…
Reference in a new issue