mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-05 15:37:24 +00:00
kube-proxy: simplify endpoints updates
We don't need the svcPortToInfoMap. Its only purpose was to send "valid" local endpoints (those with valid IP and >0 port) to the health checker. But we shouldn't be sending invalid endpoints to the health checker anyway, because it can't do anything with them. If we exclude invalid endpoints earlier, then we don't need flattenValidEndpoints(). And if we don't need flattenValidEndpoints() it makes no sense to have svcPortToInfoMap store hostPortInfo, since endpointsInfo is the same thing as hostPortInfo except with a combined host:port. And if svcPortToInfoMap now only stores valid endpointsInfos, it is exactly the same thing as newEndpoints.
This commit is contained in:
@@ -1337,8 +1337,7 @@ func Test_accumulateEndpointsMap(t *testing.T) {
|
||||
for tci, tc := range testCases {
|
||||
// outputs
|
||||
newEndpoints := map[proxy.ServicePortName][]*endpointsInfo{}
|
||||
svcPortToInfoMap := map[proxy.ServicePortName][]hostPortInfo{}
|
||||
accumulateEndpointsMap(&tc.newEndpoints, "host", tc.oldEndpoints, &newEndpoints, &svcPortToInfoMap)
|
||||
accumulateEndpointsMap(&tc.newEndpoints, "host", tc.oldEndpoints, &newEndpoints)
|
||||
|
||||
if len(newEndpoints) != len(tc.expectedNew) {
|
||||
t.Errorf("[%d] expected %d new, got %d: %v", tci, len(tc.expectedNew), len(newEndpoints), spew.Sdump(newEndpoints))
|
||||
|
||||
Reference in New Issue
Block a user