Skip to content

Commit

Permalink
Fix logging in AntreaProxy topology code (#6684)
Browse files Browse the repository at this point in the history
This fix is ​​consistent with the latest kube-proxy implementation

Fixes #6682

Signed-off-by: Hongliang Liu <lhongliang@vmware.com>
  • Loading branch information
hongliangl authored Sep 23, 2024
1 parent ad8283b commit 827bd3b
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pkg/agent/proxy/topology.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
}

Expand Down

0 comments on commit 827bd3b

Please sign in to comment.