From 4fc6d8daf54fb2ca6ed5d1eeb4c8895067966eb1 Mon Sep 17 00:00:00 2001 From: Davanum Srinivas Date: Fri, 2 Aug 2024 14:10:10 -0400 Subject: [PATCH] [kube-proxy] add log verbosity to endpoint topology hint loop - Take 2 Signed-off-by: Davanum Srinivas --- pkg/proxy/topology.go | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/pkg/proxy/topology.go b/pkg/proxy/topology.go index 9ccd359534d..10887d9bc39 100644 --- a/pkg/proxy/topology.go +++ b/pkg/proxy/topology.go @@ -160,19 +160,23 @@ func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[st } } - zone, ok := nodeLabels[v1.LabelTopologyZone] - if !ok || zone == "" { - klog.V(2).InfoS("Skipping topology aware endpoint filtering since node is missing label", "label", v1.LabelTopologyZone) - return false - } - + zone, foundZone := nodeLabels[v1.LabelTopologyZone] hasEndpointForZone := false for _, endpoint := range endpoints { if !endpoint.IsReady() { continue } + + // If any of the endpoints do not have zone hints, we bail out if endpoint.ZoneHints().Len() == 0 { - klog.V(2).InfoS("Skipping topology aware endpoint filtering since one or more endpoints is missing a zone hint", "endpoint", endpoint) + klog.V(7).InfoS("Skipping topology aware endpoint filtering since one or more endpoints is missing a zone hint", "endpoint", endpoint) + return false + } + + // If we've made it this far, we have endpoints with hints set. Now we check if there is a + // zone label, if there isn't one we log a warning and bail out + if !foundZone || zone == "" { + klog.V(2).InfoS("Skipping topology aware endpoint filtering since node is missing label", "label", v1.LabelTopologyZone) return false } @@ -182,10 +186,9 @@ func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[st } if !hasEndpointForZone { - klog.V(2).InfoS("Skipping topology aware endpoint filtering since no hints were provided for zone", "zone", zone) + klog.V(7).InfoS("Skipping topology aware endpoint filtering since no hints were provided for zone", "zone", zone) return false } - return true }