From 440cfca4ef722479d99904eb5c714563e7f8ebf1 Mon Sep 17 00:00:00 2001 From: ansilh Date: Fri, 6 Feb 2026 21:56:58 +0530 Subject: [PATCH] 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. --- pkg/proxy/topology.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pkg/proxy/topology.go b/pkg/proxy/topology.go index 9c7c7e9a258..48b2e541136 100644 --- a/pkg/proxy/topology.go +++ b/pkg/proxy/topology.go @@ -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