Merge pull request #126519 from dims/bjhaid-bjhaid-topology-verbosity-take-2

[kube-proxy] add log verbosity to endpoint topology hint loop - Take 2
This commit is contained in:
Kubernetes Prow Robot 2024-08-03 16:54:37 -07:00 committed by GitHub
commit 00236ae0d7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -160,19 +160,23 @@ func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[st
} }
} }
zone, ok := nodeLabels[v1.LabelTopologyZone] zone, foundZone := 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
}
hasEndpointForZone := false hasEndpointForZone := false
for _, endpoint := range endpoints { for _, endpoint := range endpoints {
if !endpoint.IsReady() { if !endpoint.IsReady() {
continue continue
} }
// If any of the endpoints do not have zone hints, we bail out
if endpoint.ZoneHints().Len() == 0 { 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 return false
} }
@ -182,10 +186,9 @@ func canUseTopology(endpoints []Endpoint, svcInfo ServicePort, nodeLabels map[st
} }
if !hasEndpointForZone { 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 false
} }
return true return true
} }