refactor(kube-proxy): remove redundant empty endpoints check in topologyModeFromHints

The len(endpoints) == 0 check is now redundant since the hasReadyEndpoints
check handles this case when the slice is empty, the loop executes zero
times, hasReadyEndpoints stays false, and returns "" via the same path.
This commit is contained in:
ansilh
2026-02-06 21:56:58 +05:30
parent 18f56fa7c7
commit 440cfca4ef

View File

@@ -162,12 +162,6 @@ 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