From 827bd3b239aae66cf1bde66a78bb6fa578d17ecc Mon Sep 17 00:00:00 2001 From: Hongliang Liu <75655411+hongliangl@users.noreply.github.com> Date: Tue, 24 Sep 2024 04:21:51 +0800 Subject: [PATCH] Fix logging in AntreaProxy topology code (#6684) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fix is ​​consistent with the latest kube-proxy implementation Fixes #6682 Signed-off-by: Hongliang Liu --- pkg/agent/proxy/topology.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/pkg/agent/proxy/topology.go b/pkg/agent/proxy/topology.go index 87f0160adbd..ad37601a5bc 100644 --- a/pkg/agent/proxy/topology.go +++ b/pkg/agent/proxy/topology.go @@ -133,19 +133,21 @@ func (p *proxier) canUseTopology(endpoints map[string]k8sproxy.Endpoint, svcInfo } } - zone, ok := p.nodeLabels[v1.LabelTopologyZone] - if !ok || zone == "" { - klog.InfoS("Skipping topology aware Endpoint filtering since Node is missing label", "label", v1.LabelTopologyZone) - return false - } - + zone, foundZone := p.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.GetZoneHints().Len() == 0 { - klog.InfoS("Skipping topology aware Endpoint filtering since one or more Endpoints is missing a zone hint") + klog.V(7).InfoS("Skipping topology aware Endpoint filtering since one or more Endpoints is missing a zone hint") + 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 } if endpoint.GetZoneHints().Has(zone) { @@ -154,7 +156,7 @@ func (p *proxier) canUseTopology(endpoints map[string]k8sproxy.Endpoint, svcInfo } if !hasEndpointForZone { - klog.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 }