From d4784cfe5986c4c51dc25240f92da86ac3f0d9a2 Mon Sep 17 00:00:00 2001 From: Manuel Alejandro de Brito Fontes Date: Sun, 11 Feb 2018 12:39:01 -0800 Subject: [PATCH] Always return an IP address (#2065) --- internal/k8s/main.go | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/internal/k8s/main.go b/internal/k8s/main.go index dcb887c0a..6013b5471 100644 --- a/internal/k8s/main.go +++ b/internal/k8s/main.go @@ -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