diff --git a/pkg/proxy/endpoints.go b/pkg/proxy/endpoints.go index c203199e460..b849f532d97 100644 --- a/pkg/proxy/endpoints.go +++ b/pkg/proxy/endpoints.go @@ -208,7 +208,7 @@ func UpdateEndpointsMap(endpointsMap EndpointsMap, changes *EndpointChangeTracke // TODO: If this will appear to be computationally expensive, consider // computing this incrementally similarly to endpointsMap. result.HCEndpointsLocalIPSize = make(map[types.NamespacedName]int) - localIPs := GetLocalEndpointIPs(endpointsMap) + localIPs := endpointsMap.getLocalEndpointIPs() for nsn, ips := range localIPs { result.HCEndpointsLocalIPSize[nsn] = len(ips) } @@ -316,9 +316,9 @@ func (em EndpointsMap) unmerge(other EndpointsMap) { } // GetLocalEndpointIPs returns endpoints IPs if given endpoint is local - local means the endpoint is running in same host as kube-proxy. -func GetLocalEndpointIPs(endpointsMap EndpointsMap) map[types.NamespacedName]sets.String { +func (em EndpointsMap) getLocalEndpointIPs() map[types.NamespacedName]sets.String { localIPs := make(map[types.NamespacedName]sets.String) - for svcPortName, epList := range endpointsMap { + for svcPortName, epList := range em { for _, ep := range epList { if ep.GetIsLocal() { nsn := svcPortName.NamespacedName diff --git a/pkg/proxy/endpoints_test.go b/pkg/proxy/endpoints_test.go index 650aa1da994..9f464985149 100644 --- a/pkg/proxy/endpoints_test.go +++ b/pkg/proxy/endpoints_test.go @@ -112,7 +112,7 @@ func TestGetLocalEndpointIPs(t *testing.T) { for tci, tc := range testCases { // outputs - localIPs := GetLocalEndpointIPs(tc.endpointsMap) + localIPs := tc.endpointsMap.getLocalEndpointIPs() if !reflect.DeepEqual(localIPs, tc.expected) { t.Errorf("[%d] expected %#v, got %#v", tci, tc.expected, localIPs)