mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 16:29:21 +00:00
Cleanup of GetLocalEndpointIPs
unexported GetLocalEndpointIPs and made it a endpointsMap struct method
This commit is contained in:
parent
1d60557c87
commit
5201cc994c
@ -208,7 +208,7 @@ func UpdateEndpointsMap(endpointsMap EndpointsMap, changes *EndpointChangeTracke
|
|||||||
// TODO: If this will appear to be computationally expensive, consider
|
// TODO: If this will appear to be computationally expensive, consider
|
||||||
// computing this incrementally similarly to endpointsMap.
|
// computing this incrementally similarly to endpointsMap.
|
||||||
result.HCEndpointsLocalIPSize = make(map[types.NamespacedName]int)
|
result.HCEndpointsLocalIPSize = make(map[types.NamespacedName]int)
|
||||||
localIPs := GetLocalEndpointIPs(endpointsMap)
|
localIPs := endpointsMap.getLocalEndpointIPs()
|
||||||
for nsn, ips := range localIPs {
|
for nsn, ips := range localIPs {
|
||||||
result.HCEndpointsLocalIPSize[nsn] = len(ips)
|
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.
|
// 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)
|
localIPs := make(map[types.NamespacedName]sets.String)
|
||||||
for svcPortName, epList := range endpointsMap {
|
for svcPortName, epList := range em {
|
||||||
for _, ep := range epList {
|
for _, ep := range epList {
|
||||||
if ep.GetIsLocal() {
|
if ep.GetIsLocal() {
|
||||||
nsn := svcPortName.NamespacedName
|
nsn := svcPortName.NamespacedName
|
||||||
|
@ -112,7 +112,7 @@ func TestGetLocalEndpointIPs(t *testing.T) {
|
|||||||
|
|
||||||
for tci, tc := range testCases {
|
for tci, tc := range testCases {
|
||||||
// outputs
|
// outputs
|
||||||
localIPs := GetLocalEndpointIPs(tc.endpointsMap)
|
localIPs := tc.endpointsMap.getLocalEndpointIPs()
|
||||||
|
|
||||||
if !reflect.DeepEqual(localIPs, tc.expected) {
|
if !reflect.DeepEqual(localIPs, tc.expected) {
|
||||||
t.Errorf("[%d] expected %#v, got %#v", tci, tc.expected, localIPs)
|
t.Errorf("[%d] expected %#v, got %#v", tci, tc.expected, localIPs)
|
||||||
|
Loading…
Reference in New Issue
Block a user