Merge pull request #136743 from ansilh/master

fix(kube-proxy): skip topology hints logging when no ready endpoints exist
This commit is contained in:
Kubernetes Prow Robot
2026-02-06 23:06:36 +05:30
committed by GitHub
2 changed files with 16 additions and 6 deletions

View File

@@ -162,12 +162,7 @@ func CategorizeEndpoints(endpoints []Endpoint, svcInfo ServicePort, nodeName str
// hinted for this node's zone, then it returns "PreferSameZone".
// - Otherwise it returns "" (meaning, no topology / default traffic distribution).
func topologyModeFromHints(svcInfo ServicePort, endpoints []Endpoint, nodeName, zone string) string {
if len(endpoints) == 0 {
// The code below assumes at least 1 endpoint; if there are no endpoints,
// there are no hints.
return ""
}
hasReadyEndpoints := false
hasEndpointForNode := false
allEndpointsHaveNodeHints := true
hasEndpointForZone := false
@@ -176,6 +171,7 @@ func topologyModeFromHints(svcInfo ServicePort, endpoints []Endpoint, nodeName,
if !endpoint.IsReady() {
continue
}
hasReadyEndpoints = true
if endpoint.NodeHints().Len() == 0 {
allEndpointsHaveNodeHints = false
@@ -190,6 +186,11 @@ func topologyModeFromHints(svcInfo ServicePort, endpoints []Endpoint, nodeName,
}
}
// If no ready endpoints exist, there are no hints to consider
if !hasReadyEndpoints {
return ""
}
if utilfeature.DefaultFeatureGate.Enabled(features.PreferSameTrafficDistribution) {
if allEndpointsHaveNodeHints {
if hasEndpointForNode {

View File

@@ -398,6 +398,15 @@ func TestCategorizeEndpoints(t *testing.T) {
clusterEndpoints: nil,
localEndpoints: nil,
allEndpoints: nil,
}, {
name: "single endpoint not ready, not serving, not terminating",
nodeLabels: map[string]string{v1.LabelTopologyZone: "zone-a"},
serviceInfo: &BaseServicePortInfo{},
endpoints: []Endpoint{
&BaseEndpointInfo{endpoint: "10.0.0.0:80", ready: false, serving: false, terminating: false},
},
clusterEndpoints: sets.New[string](),
localEndpoints: nil,
}}
for _, tc := range testCases {