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:
Dan Williams
2017-03-07 13:32:02 -06:00
parent 0fad9ce5e2
commit 76a7d690db
2 changed files with 21 additions and 77 deletions

View File

@@ -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))