diff --git a/pkg/proxy/endpoints.go b/pkg/proxy/endpoints.go index 36e6e98bacd..8ecf82fddf9 100644 --- a/pkg/proxy/endpoints.go +++ b/pkg/proxy/endpoints.go @@ -30,7 +30,6 @@ import ( "k8s.io/apimachinery/pkg/types" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/kubernetes/pkg/proxy/metrics" - proxyutil "k8s.io/kubernetes/pkg/proxy/util" ) var supportedEndpointSliceAddressTypes = sets.New[string]( @@ -43,7 +42,11 @@ var supportedEndpointSliceAddressTypes = sets.New[string]( // or can be used for constructing a more specific EndpointInfo struct // defined by the proxier if needed. type BaseEndpointInfo struct { - endpoint string // TODO: should be an endpointString type + // Cache this values to improve performance + ip string + port int + // endpoint is the same as net.JoinHostPort(ip,port) + endpoint string // isLocal indicates whether the endpoint is running on same host as kube-proxy. isLocal bool @@ -73,12 +76,12 @@ func (info *BaseEndpointInfo) String() string { // IP returns just the IP part of the endpoint, it's a part of proxy.Endpoint interface. func (info *BaseEndpointInfo) IP() string { - return proxyutil.IPPart(info.endpoint) + return info.ip } // Port returns just the Port part of the endpoint. -func (info *BaseEndpointInfo) Port() (int, error) { - return proxyutil.PortPart(info.endpoint) +func (info *BaseEndpointInfo) Port() int { + return info.port } // IsLocal is part of proxy.Endpoint interface. @@ -110,6 +113,8 @@ func (info *BaseEndpointInfo) ZoneHints() sets.Set[string] { func newBaseEndpointInfo(ip string, port int, isLocal, ready, serving, terminating bool, zoneHints sets.Set[string]) *BaseEndpointInfo { return &BaseEndpointInfo{ + ip: ip, + port: port, endpoint: net.JoinHostPort(ip, strconv.Itoa(port)), isLocal: isLocal, ready: ready, diff --git a/pkg/proxy/endpoints_test.go b/pkg/proxy/endpoints_test.go index b429cfcee7c..62e46d1cd0e 100644 --- a/pkg/proxy/endpoints_test.go +++ b/pkg/proxy/endpoints_test.go @@ -54,7 +54,7 @@ func TestGetLocalEndpointIPs(t *testing.T) { // Case[1]: unnamed port endpointsMap: EndpointsMap{ makeServicePortName("ns1", "ep1", "", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expected: map[types.NamespacedName]sets.Set[string]{}, @@ -62,7 +62,7 @@ func TestGetLocalEndpointIPs(t *testing.T) { // Case[2]: unnamed port local endpointsMap: EndpointsMap{ makeServicePortName("ns1", "ep1", "", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expected: map[types.NamespacedName]sets.Set[string]{ @@ -72,12 +72,12 @@ func TestGetLocalEndpointIPs(t *testing.T) { // Case[3]: named local and non-local ports for the same IP. endpointsMap: EndpointsMap{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.2", port: 11, endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expected: map[types.NamespacedName]sets.Set[string]{ @@ -87,21 +87,21 @@ func TestGetLocalEndpointIPs(t *testing.T) { // Case[4]: named local and non-local ports for different IPs. endpointsMap: EndpointsMap{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p22", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "2.2.2.22:22", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "2.2.2.2", port: 22, endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "2.2.2.22", port: 22, endpoint: "2.2.2.22:22", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p23", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "2.2.2.3:23", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "2.2.2.3", port: 23, endpoint: "2.2.2.3:23", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns4", "ep4", "p44", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "4.4.4.5:44", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "4.4.4.4", port: 44, endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "4.4.4.5", port: 44, endpoint: "4.4.4.5:44", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns4", "ep4", "p45", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "4.4.4.6:45", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "4.4.4.6", port: 45, endpoint: "4.4.4.6:45", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expected: map[types.NamespacedName]sets.Set[string]{ @@ -112,21 +112,21 @@ func TestGetLocalEndpointIPs(t *testing.T) { // Case[5]: named local and non-local ports for different IPs, some not ready. endpointsMap: EndpointsMap{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p22", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "2.2.2.22:22", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "2.2.2.2", port: 22, endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "2.2.2.22", port: 22, endpoint: "2.2.2.22:22", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p23", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "2.2.2.3:23", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "2.2.2.3", port: 23, endpoint: "2.2.2.3:23", isLocal: true, ready: false, serving: true, terminating: true}, }, makeServicePortName("ns4", "ep4", "p44", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "4.4.4.5:44", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "4.4.4.4", port: 44, endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "4.4.4.5", port: 44, endpoint: "4.4.4.5:44", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns4", "ep4", "p45", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "4.4.4.6:45", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "4.4.4.6", port: 45, endpoint: "4.4.4.6:45", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expected: map[types.NamespacedName]sets.Set[string]{ @@ -137,21 +137,21 @@ func TestGetLocalEndpointIPs(t *testing.T) { // Case[6]: all endpoints are terminating,, so getLocalReadyEndpointIPs should return 0 ready endpoints endpointsMap: EndpointsMap{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "1.1.1.1:11", isLocal: false, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: false, serving: true, terminating: true}, }, makeServicePortName("ns2", "ep2", "p22", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "2.2.2.2:22", isLocal: true, ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "2.2.2.22:22", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "2.2.2.2", port: 22, endpoint: "2.2.2.2:22", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "2.2.2.22", port: 22, endpoint: "2.2.2.22:22", isLocal: true, ready: false, serving: true, terminating: true}, }, makeServicePortName("ns2", "ep2", "p23", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "2.2.2.3:23", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "2.2.2.3", port: 23, endpoint: "2.2.2.3:23", isLocal: true, ready: false, serving: true, terminating: true}, }, makeServicePortName("ns4", "ep4", "p44", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "4.4.4.4:44", isLocal: true, ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "4.4.4.5:44", isLocal: false, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "4.4.4.4", port: 44, endpoint: "4.4.4.4:44", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "4.4.4.5", port: 44, endpoint: "4.4.4.5:44", isLocal: false, ready: false, serving: true, terminating: true}, }, makeServicePortName("ns4", "ep4", "p45", v1.ProtocolTCP): []Endpoint{ - &BaseEndpointInfo{endpoint: "4.4.4.6:45", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "4.4.4.6", port: 45, endpoint: "4.4.4.6:45", isLocal: true, ready: false, serving: true, terminating: true}, }, }, expected: make(map[types.NamespacedName]sets.Set[string], 0), @@ -555,12 +555,12 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -577,12 +577,12 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -603,18 +603,18 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -633,24 +633,24 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): { - {endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.3", port: 13, endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): { - {endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.3", port: 13, endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -673,54 +673,54 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 11, endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): { - {endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.4:13", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.3", port: 13, endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.4", port: 13, endpoint: "1.1.1.4:13", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): { - {endpoint: "1.1.1.3:14", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.4:14", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.3", port: 14, endpoint: "1.1.1.3:14", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.4", port: 14, endpoint: "1.1.1.4:14", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): { - {endpoint: "2.2.2.1:21", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "2.2.2.2:21", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.1", port: 21, endpoint: "2.2.2.1:21", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.2", port: 21, endpoint: "2.2.2.2:21", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): { - {endpoint: "2.2.2.1:22", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.1", port: 22, endpoint: "2.2.2.1:22", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.2", port: 22, endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 11, endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): { - {endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.4:13", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.3", port: 13, endpoint: "1.1.1.3:13", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.4", port: 13, endpoint: "1.1.1.4:13", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): { - {endpoint: "1.1.1.3:14", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.4:14", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.3", port: 14, endpoint: "1.1.1.3:14", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.4", port: 14, endpoint: "1.1.1.4:14", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): { - {endpoint: "2.2.2.1:21", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "2.2.2.2:21", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.1", port: 21, endpoint: "2.2.2.1:21", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.2", port: 21, endpoint: "2.2.2.2:21", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): { - {endpoint: "2.2.2.1:22", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.1", port: 22, endpoint: "2.2.2.1:22", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.2", port: 22, endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -741,7 +741,7 @@ func TestUpdateEndpointsMap(t *testing.T) { previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{}, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -762,7 +762,7 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{}, @@ -783,17 +783,17 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 11, endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -814,17 +814,17 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 11, endpoint: "1.1.1.2:11", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 12, endpoint: "1.1.1.1:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{{ @@ -852,15 +852,15 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -883,15 +883,15 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{{ @@ -911,12 +911,12 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{{ @@ -938,12 +938,12 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:22", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 22, endpoint: "1.1.1.1:22", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{{ @@ -983,39 +983,39 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): { - {endpoint: "2.2.2.22:22", isLocal: true, ready: true, serving: true, terminating: false}, - {endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.22", port: 22, endpoint: "2.2.2.22:22", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.2", port: 22, endpoint: "2.2.2.2:22", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP): { - {endpoint: "2.2.2.3:23", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "2.2.2.3", port: 23, endpoint: "2.2.2.3:23", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): { - {endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, - {endpoint: "4.4.4.5:44", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "4.4.4.4", port: 44, endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "4.4.4.5", port: 44, endpoint: "4.4.4.5:44", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP): { - {endpoint: "4.4.4.6:45", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "4.4.4.6", port: 45, endpoint: "4.4.4.6:45", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): { - {endpoint: "1.1.1.11:11", isLocal: false, ready: true, serving: true, terminating: false}, - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.11", port: 11, endpoint: "1.1.1.11:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): { - {endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 12, endpoint: "1.1.1.2:12", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): { - {endpoint: "1.1.1.2:122", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.2", port: 122, endpoint: "1.1.1.2:122", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): { - {endpoint: "3.3.3.3:33", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "3.3.3.3", port: 33, endpoint: "3.3.3.3:33", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): { - {endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, + {ip: "4.4.4.4", port: 44, endpoint: "4.4.4.4:44", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{{ @@ -1054,7 +1054,7 @@ func TestUpdateEndpointsMap(t *testing.T) { previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{}, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -1073,12 +1073,12 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: false, serving: true, terminating: true}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: false, serving: true, terminating: true}, }, }, expectedDeletedUDPEndpoints: []ServiceEndpoint{}, @@ -1095,7 +1095,7 @@ func TestUpdateEndpointsMap(t *testing.T) { }, previousEndpointsMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): { - {endpoint: "1.1.1.1:11", isLocal: false, ready: false, serving: true, terminating: true}, + {ip: "1.1.1.1", port: 11, endpoint: "1.1.1.1:11", isLocal: false, ready: false, serving: true, terminating: true}, }, }, expectedResult: map[ServicePortName][]*BaseEndpointInfo{}, @@ -1358,14 +1358,14 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: false, ready: true, serving: true, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1409,22 +1409,22 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.5:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 80, endpoint: "10.0.1.4:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.5", port: 80, endpoint: "10.0.1.5:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 80, endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 80, endpoint: "10.0.2.2:80", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.5:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 443, endpoint: "10.0.1.4:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.5", port: 443, endpoint: "10.0.1.5:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 443, endpoint: "10.0.2.1:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 443, endpoint: "10.0.2.2:443", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1442,20 +1442,20 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.5:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 80, endpoint: "10.0.1.4:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.5", port: 80, endpoint: "10.0.1.5:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 80, endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 80, endpoint: "10.0.2.2:80", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 443, endpoint: "10.0.2.1:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 443, endpoint: "10.0.2.2:443", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1473,12 +1473,12 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 80, endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 80, endpoint: "10.0.2.2:80", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.2.1:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 443, endpoint: "10.0.2.1:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 443, endpoint: "10.0.2.2:443", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1509,14 +1509,14 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: true, ready: false, serving: false, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: true, ready: false, serving: false, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1533,12 +1533,12 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1556,18 +1556,18 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:80", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 80, endpoint: "10.0.2.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 80, endpoint: "10.0.2.2:80", isLocal: true, ready: false, serving: false, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:443", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 443, endpoint: "10.0.2.1:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 443, endpoint: "10.0.2.2:443", isLocal: true, ready: false, serving: false, terminating: false}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1585,18 +1585,18 @@ func TestEndpointSliceUpdate(t *testing.T) { expectedReturnVal: true, expectedCurrentChange: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:80", isLocal: true, ready: false, serving: false, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 80, endpoint: "10.0.2.1:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 80, endpoint: "10.0.2.2:80", isLocal: true, ready: false, serving: false, terminating: true}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: true, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:443", isLocal: true, ready: false, serving: false, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: true, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 443, endpoint: "10.0.2.1:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 443, endpoint: "10.0.2.2:443", isLocal: true, ready: false, serving: false, terminating: true}, }, }, expectedChangedEndpoints: sets.New[string]("ns1/svc1"), @@ -1655,9 +1655,9 @@ func TestCheckoutChanges(t *testing.T) { previous: EndpointsMap{}, current: EndpointsMap{ svcPortName0: []Endpoint{ - &BaseEndpointInfo{endpoint: "10.0.1.1:80", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", ready: false, serving: false, terminating: false}, }, }, }}, @@ -1671,21 +1671,21 @@ func TestCheckoutChanges(t *testing.T) { expectedChanges: []*endpointsChange{{ previous: EndpointsMap{ svcPortName0: []Endpoint{ - &BaseEndpointInfo{endpoint: "10.0.1.1:80", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", ready: false, serving: false, terminating: false}, }, svcPortName1: []Endpoint{ - &BaseEndpointInfo{endpoint: "10.0.1.1:443", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", ready: false, serving: false, terminating: false}, }, }, current: EndpointsMap{ svcPortName0: []Endpoint{ - &BaseEndpointInfo{endpoint: "10.0.1.1:80", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", ready: false, serving: false, terminating: false}, }, }, }}, diff --git a/pkg/proxy/endpointslicecache_test.go b/pkg/proxy/endpointslicecache_test.go index 6d2d4a58756..6b4b503e73e 100644 --- a/pkg/proxy/endpointslicecache_test.go +++ b/pkg/proxy/endpointslicecache_test.go @@ -44,14 +44,14 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, }, makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:443", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 443, endpoint: "10.0.1.1:443", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 443, endpoint: "10.0.1.2:443", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 443, endpoint: "10.0.1.3:443", isLocal: false, ready: true, serving: true, terminating: false}, }, }, }, @@ -63,12 +63,12 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.2:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.2.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.1", port: 80, endpoint: "10.0.2.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.2", port: 80, endpoint: "10.0.2.2:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.2.3", port: 80, endpoint: "10.0.2.3:80", isLocal: false, ready: true, serving: true, terminating: false}, }, }, }, @@ -82,10 +82,10 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 80, endpoint: "10.0.1.4:80", isLocal: false, ready: true, serving: true, terminating: false}, }, }, }, @@ -101,16 +101,16 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.10:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.5:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.6:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.7:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.8:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.9:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.10", port: 80, endpoint: "10.0.1.10:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 80, endpoint: "10.0.1.4:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.5", port: 80, endpoint: "10.0.1.5:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.6", port: 80, endpoint: "10.0.1.6:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.7", port: 80, endpoint: "10.0.1.7:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.8", port: 80, endpoint: "10.0.1.8:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.9", port: 80, endpoint: "10.0.1.9:80", isLocal: false, ready: true, serving: true, terminating: false}, }, }, }, @@ -123,16 +123,16 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.10:80", isLocal: false, ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.5:80", isLocal: false, ready: false, serving: true, terminating: true}, - &BaseEndpointInfo{endpoint: "10.0.1.6:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.7:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.8:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.9:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.10", port: 80, endpoint: "10.0.1.10:80", isLocal: false, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 80, endpoint: "10.0.1.4:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.5", port: 80, endpoint: "10.0.1.5:80", isLocal: false, ready: false, serving: true, terminating: true}, + &BaseEndpointInfo{ip: "10.0.1.6", port: 80, endpoint: "10.0.1.6:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.7", port: 80, endpoint: "10.0.1.7:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.8", port: 80, endpoint: "10.0.1.8:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.9", port: 80, endpoint: "10.0.1.9:80", isLocal: false, ready: true, serving: true, terminating: false}, }, }, }, @@ -144,16 +144,16 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.10:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.4:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.5:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.6:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.7:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.8:80", isLocal: false, ready: false, serving: false, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.9:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.10", port: 80, endpoint: "10.0.1.10:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.4", port: 80, endpoint: "10.0.1.4:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.5", port: 80, endpoint: "10.0.1.5:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.6", port: 80, endpoint: "10.0.1.6:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.7", port: 80, endpoint: "10.0.1.7:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.8", port: 80, endpoint: "10.0.1.8:80", isLocal: false, ready: false, serving: false, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.9", port: 80, endpoint: "10.0.1.9:80", isLocal: false, ready: false, serving: false, terminating: false}, }, }, }, @@ -166,9 +166,9 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.3", port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, serving: true, terminating: false}, }, }, }, @@ -193,10 +193,10 @@ func TestEndpointsMapFromESC(t *testing.T) { }, expectedMap: map[ServicePortName][]*BaseEndpointInfo{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { - &BaseEndpointInfo{endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.1:8080", isLocal: false, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, - &BaseEndpointInfo{endpoint: "10.0.1.2:8080", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.1", port: 8080, endpoint: "10.0.1.1:8080", isLocal: false, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, serving: true, terminating: false}, + &BaseEndpointInfo{ip: "10.0.1.2", port: 8080, endpoint: "10.0.1.2:8080", isLocal: true, ready: true, serving: true, terminating: false}, }, }, }, @@ -233,6 +233,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { expectedMap: spToEndpointMap{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { "10.0.1.1:80": &BaseEndpointInfo{ + ip: "10.0.1.1", + port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, @@ -240,6 +242,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { terminating: false, }, "10.0.1.2:80": &BaseEndpointInfo{ + ip: "10.0.1.2", + port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, @@ -247,6 +251,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { terminating: false, }, "10.0.1.3:80": &BaseEndpointInfo{ + ip: "10.0.1.3", + port: 80, endpoint: "10.0.1.3:80", isLocal: false, ready: true, @@ -266,6 +272,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { expectedMap: spToEndpointMap{ makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): { "10.0.1.1:80": &BaseEndpointInfo{ + ip: "10.0.1.1", + port: 80, endpoint: "10.0.1.1:80", isLocal: false, ready: true, @@ -273,6 +281,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { terminating: false, }, "10.0.1.2:80": &BaseEndpointInfo{ + ip: "10.0.1.2", + port: 80, endpoint: "10.0.1.2:80", isLocal: true, ready: true, @@ -280,6 +290,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { terminating: false, }, "10.0.1.1:8080": &BaseEndpointInfo{ + ip: "10.0.1.1", + port: 8080, endpoint: "10.0.1.1:8080", isLocal: false, ready: true, @@ -287,6 +299,8 @@ func TestEndpointInfoByServicePort(t *testing.T) { terminating: false, }, "10.0.1.2:8080": &BaseEndpointInfo{ + ip: "10.0.1.2", + port: 8080, endpoint: "10.0.1.2:8080", isLocal: true, ready: true, diff --git a/pkg/proxy/ipvs/proxier.go b/pkg/proxy/ipvs/proxier.go index bf68149199b..70744352982 100644 --- a/pkg/proxy/ipvs/proxier.go +++ b/pkg/proxy/ipvs/proxier.go @@ -1066,9 +1066,9 @@ func (proxier *Proxier) syncProxyRules() { continue } epIP := ep.IP() - epPort, err := ep.Port() + epPort := ep.Port() // Error parsing this endpoint has been logged. Skip to next endpoint. - if epIP == "" || err != nil { + if epIP == "" || epPort == 0 { continue } entry := &utilipset.Entry{ diff --git a/pkg/proxy/types.go b/pkg/proxy/types.go index 5bb3bbefe9d..fbb46cc959b 100644 --- a/pkg/proxy/types.go +++ b/pkg/proxy/types.go @@ -111,7 +111,7 @@ type Endpoint interface { // IP returns IP part of the endpoint. IP() string // Port returns the Port part of the endpoint. - Port() (int, error) + Port() int // IsLocal returns true if the endpoint is running on the same host as kube-proxy. IsLocal() bool diff --git a/pkg/proxy/winkernel/proxier.go b/pkg/proxy/winkernel/proxier.go index 3682d00e9c0..02210e99494 100644 --- a/pkg/proxy/winkernel/proxier.go +++ b/pkg/proxy/winkernel/proxier.go @@ -325,8 +325,8 @@ func (info *endpointInfo) IP() string { } // Port returns just the Port part of the endpoint. -func (info *endpointInfo) Port() (int, error) { - return int(info.port), nil +func (info *endpointInfo) Port() int { + return int(info.port) } // Uses mac prefix and IPv4 address to return a mac address @@ -436,15 +436,9 @@ func (proxier *Proxier) onServiceMapChange(svcPortName *proxy.ServicePortName) { // returns a new proxy.Endpoint which abstracts a endpointInfo func (proxier *Proxier) newEndpointInfo(baseInfo *proxy.BaseEndpointInfo, _ *proxy.ServicePortName) proxy.Endpoint { - portNumber, err := baseInfo.Port() - - if err != nil { - portNumber = 0 - } - info := &endpointInfo{ ip: baseInfo.IP(), - port: uint16(portNumber), + port: uint16(baseInfo.Port()), isLocal: baseInfo.IsLocal(), macAddress: conjureMac("02-11", netutils.ParseIPSloppy(baseInfo.IP())), refCount: new(uint16),