From 709da7f2c41cb92423422149e54193b9b4c59689 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 30 Sep 2024 02:22:56 +0000 Subject: [PATCH 1/2] Remove redundant parentheses --- pkg/controller/controller.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 8b6482b4..7adb8ea1 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -1305,7 +1305,7 @@ func (lbc *LoadBalancerController) createIngressUpstreams(ctx context.Context, i reqPath = reqPath[:idx] } - if lbc.noDefaultBackendOverride && (rule.Host == "" && (reqPath == "" || reqPath == "/")) { + if lbc.noDefaultBackendOverride && rule.Host == "" && (reqPath == "" || reqPath == "/") { log.Error(nil, "Ignore rule which overrides default backend") continue } From 574a5f327e8d12a64e2b58a8b1af365a9786c9b9 Mon Sep 17 00:00:00 2001 From: Tatsuhiro Tsujikawa Date: Mon, 30 Sep 2024 02:25:05 +0000 Subject: [PATCH 2/2] getPodNodeAddress: Simplify --- pkg/controller/controller.go | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/pkg/controller/controller.go b/pkg/controller/controller.go index 7adb8ea1..c76a9e33 100644 --- a/pkg/controller/controller.go +++ b/pkg/controller/controller.go @@ -3239,19 +3239,16 @@ func (lc *LeaderController) getPodNodeAddress(pod *corev1.Pod) (string, error) { for i := range node.Status.Addresses { address := &node.Status.Addresses[i] - if address.Type == corev1.NodeExternalIP { - if address.Address == "" { - continue + switch address.Type { + case corev1.NodeExternalIP: + if address.Address != "" { + return address.Address, nil + } + case corev1.NodeInternalIP: + if externalIP == "" && lc.lbc.allowInternalIP { + // Continue to the next iteration because we may encounter v1.NodeExternalIP later. + externalIP = address.Address } - - externalIP = address.Address - - break - } - - if externalIP == "" && lc.lbc.allowInternalIP && address.Type == corev1.NodeInternalIP { - // Continue to the next iteration because we may encounter v1.NodeExternalIP later. - externalIP = address.Address } }