mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 19:56:01 +00:00
Only detecting stale connections for UDP ports in kube-proxy.
The detectStaleConnections function in kube-proxy is very expensive in terms of CPU utilization. The results of this function are only actually used for UDP ports. This adds a protocol attribute to ServicePortName to make it simple to only run this function for UDP connections. For clusters with primarily TCP connections this can improve kube-proxy performance by 2x.
This commit is contained in:
parent
45f7f70479
commit
af56f25797
@ -315,6 +315,7 @@ func (ect *EndpointChangeTracker) endpointsToEndpointsMap(endpoints *v1.Endpoint
|
||||
svcPortName := ServicePortName{
|
||||
NamespacedName: types.NamespacedName{Namespace: endpoints.Namespace, Name: endpoints.Name},
|
||||
Port: port.Name,
|
||||
Protocol: port.Protocol,
|
||||
}
|
||||
for i := range ss.Addresses {
|
||||
addr := &ss.Addresses[i]
|
||||
@ -410,6 +411,10 @@ func (em EndpointsMap) getLocalEndpointIPs() map[types.NamespacedName]sets.Strin
|
||||
// is used to store stale udp service in order to clear udp conntrack later.
|
||||
func detectStaleConnections(oldEndpointsMap, newEndpointsMap EndpointsMap, staleEndpoints *[]ServiceEndpoint, staleServiceNames *[]ServicePortName) {
|
||||
for svcPortName, epList := range oldEndpointsMap {
|
||||
if svcPortName.Protocol != v1.ProtocolUDP {
|
||||
continue
|
||||
}
|
||||
|
||||
for _, ep := range epList {
|
||||
stale := true
|
||||
for i := range newEndpointsMap[svcPortName] {
|
||||
@ -426,6 +431,10 @@ func detectStaleConnections(oldEndpointsMap, newEndpointsMap EndpointsMap, stale
|
||||
}
|
||||
|
||||
for svcPortName, epList := range newEndpointsMap {
|
||||
if svcPortName.Protocol != v1.ProtocolUDP {
|
||||
continue
|
||||
}
|
||||
|
||||
// For udp service, if its backend changes from 0 to non-0. There may exist a conntrack entry that could blackhole traffic to the service.
|
||||
if len(epList) > 0 && len(oldEndpointsMap[svcPortName]) == 0 {
|
||||
*staleServiceNames = append(*staleServiceNames, svcPortName)
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -145,8 +145,11 @@ func (cache *EndpointSliceCache) endpointInfoByServicePort(serviceNN types.Names
|
||||
continue
|
||||
}
|
||||
|
||||
svcPortName := ServicePortName{NamespacedName: serviceNN}
|
||||
svcPortName.Port = *port.Name
|
||||
svcPortName := ServicePortName{
|
||||
NamespacedName: serviceNN,
|
||||
Port: *port.Name,
|
||||
Protocol: *port.Protocol,
|
||||
}
|
||||
|
||||
endpointInfoBySP[svcPortName] = cache.addEndpointsByIP(serviceNN, int(*port.Port), endpointInfoBySP[svcPortName], sliceInfo.Endpoints)
|
||||
}
|
||||
|
@ -21,6 +21,7 @@ import (
|
||||
"reflect"
|
||||
"testing"
|
||||
|
||||
"k8s.io/api/core/v1"
|
||||
discovery "k8s.io/api/discovery/v1alpha1"
|
||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||
"k8s.io/apimachinery/pkg/types"
|
||||
@ -41,12 +42,12 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
||||
generateEndpointSlice("svc1", "ns1", 1, 3, 999, []string{"host1", "host2"}, []*int32{utilpointer.Int32Ptr(80), utilpointer.Int32Ptr(443)}),
|
||||
},
|
||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
||||
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80", IsLocal: false},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80", IsLocal: true},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "svc1", "port-1"): {
|
||||
makeServicePortName("ns1", "svc1", "port-1", v1.ProtocolTCP): {
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:443", IsLocal: false},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:443", IsLocal: true},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:443", IsLocal: false},
|
||||
@ -60,7 +61,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
||||
generateEndpointSlice("svc1", "ns1", 2, 3, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||
},
|
||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
||||
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
||||
@ -79,7 +80,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
||||
generateEndpointSlice("svc1", "ns1", 1, 4, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||
},
|
||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
||||
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
||||
@ -98,7 +99,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
||||
generateEndpointSlice("svc1", "ns1", 1, 10, 6, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||
},
|
||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
||||
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.10:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||
@ -127,7 +128,7 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
||||
generateEndpointSlice("svc1", "ns2", 3, 3, 999, []string{}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||
},
|
||||
expectedMap: map[ServicePortName][]*BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "svc1", "port-0"): {
|
||||
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.1:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.2:80"},
|
||||
&BaseEndpointInfo{Endpoint: "10.0.1.3:80"},
|
||||
@ -148,13 +149,15 @@ func TestEndpointsMapFromESC(t *testing.T) {
|
||||
}
|
||||
|
||||
for name, tc := range testCases {
|
||||
esCache := NewEndpointSliceCache(tc.hostname, nil, nil, nil)
|
||||
t.Run(name, func(t *testing.T) {
|
||||
esCache := NewEndpointSliceCache(tc.hostname, nil, nil, nil)
|
||||
|
||||
for _, endpointSlice := range tc.endpointSlices {
|
||||
esCache.Update(endpointSlice)
|
||||
}
|
||||
for _, endpointSlice := range tc.endpointSlices {
|
||||
esCache.Update(endpointSlice)
|
||||
}
|
||||
|
||||
compareEndpointsMapsStr(t, name, esCache.EndpointsMap(tc.namespacedName), tc.expectedMap)
|
||||
compareEndpointsMapsStr(t, esCache.EndpointsMap(tc.namespacedName), tc.expectedMap)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +175,7 @@ func TestEndpointInfoByServicePort(t *testing.T) {
|
||||
generateEndpointSlice("svc1", "ns1", 1, 3, 999, []string{"host1", "host2"}, []*int32{utilpointer.Int32Ptr(80)}),
|
||||
},
|
||||
expectedMap: spToEndpointMap{
|
||||
{NamespacedName: types.NamespacedName{Name: "svc1", Namespace: "ns1"}, Port: "port-0"}: {
|
||||
makeServicePortName("ns1", "svc1", "port-0", v1.ProtocolTCP): {
|
||||
"10.0.1.1": &BaseEndpointInfo{Endpoint: "10.0.1.1:80", IsLocal: false},
|
||||
"10.0.1.2": &BaseEndpointInfo{Endpoint: "10.0.1.2:80", IsLocal: true},
|
||||
"10.0.1.3": &BaseEndpointInfo{Endpoint: "10.0.1.3:80", IsLocal: false},
|
||||
@ -198,6 +201,8 @@ func TestEndpointInfoByServicePort(t *testing.T) {
|
||||
|
||||
func generateEndpointSliceWithOffset(serviceName, namespace string, sliceNum, offset, numEndpoints, unreadyMod int, hosts []string, portNums []*int32) *discovery.EndpointSlice {
|
||||
ipAddressType := discovery.AddressTypeIP
|
||||
tcpProtocol := v1.ProtocolTCP
|
||||
|
||||
endpointSlice := &discovery.EndpointSlice{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fmt.Sprintf("%s-%d", serviceName, sliceNum),
|
||||
@ -211,8 +216,9 @@ func generateEndpointSliceWithOffset(serviceName, namespace string, sliceNum, of
|
||||
|
||||
for i, portNum := range portNums {
|
||||
endpointSlice.Ports = append(endpointSlice.Ports, discovery.EndpointPort{
|
||||
Name: utilpointer.StringPtr(fmt.Sprintf("port-%d", i)),
|
||||
Port: portNum,
|
||||
Name: utilpointer.StringPtr(fmt.Sprintf("port-%d", i)),
|
||||
Port: portNum,
|
||||
Protocol: &tcpProtocol,
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -279,6 +279,7 @@ func TestDeleteEndpointConnections(t *testing.T) {
|
||||
svc := proxy.ServicePortName{
|
||||
NamespacedName: types.NamespacedName{Namespace: "ns1", Name: tc.svcName},
|
||||
Port: "p80",
|
||||
Protocol: tc.protocol,
|
||||
}
|
||||
input := []proxy.ServiceEndpoint{
|
||||
{
|
||||
@ -627,6 +628,7 @@ func TestClusterIPEndpointsJump(t *testing.T) {
|
||||
svcPortName := proxy.ServicePortName{
|
||||
NamespacedName: makeNSN("ns1", "svc1"),
|
||||
Port: "p80",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}
|
||||
|
||||
makeServiceMap(fp,
|
||||
@ -648,8 +650,9 @@ func TestClusterIPEndpointsJump(t *testing.T) {
|
||||
IP: epIP,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -686,6 +689,7 @@ func TestLoadBalancer(t *testing.T) {
|
||||
svcPortName := proxy.ServicePortName{
|
||||
NamespacedName: makeNSN("ns1", "svc1"),
|
||||
Port: "p80",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}
|
||||
|
||||
makeServiceMap(fp,
|
||||
@ -712,8 +716,9 @@ func TestLoadBalancer(t *testing.T) {
|
||||
IP: epIP,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -745,6 +750,7 @@ func TestNodePort(t *testing.T) {
|
||||
svcPortName := proxy.ServicePortName{
|
||||
NamespacedName: makeNSN("ns1", "svc1"),
|
||||
Port: "p80",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}
|
||||
|
||||
makeServiceMap(fp,
|
||||
@ -768,8 +774,9 @@ func TestNodePort(t *testing.T) {
|
||||
IP: epIP,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -890,6 +897,7 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
||||
svcPortName := proxy.ServicePortName{
|
||||
NamespacedName: makeNSN("ns1", "svc1"),
|
||||
Port: "p80",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}
|
||||
svcSessionAffinityTimeout := int32(10800)
|
||||
|
||||
@ -929,8 +937,9 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
||||
NodeName: utilpointer.StringPtr(testHostname),
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -991,6 +1000,7 @@ func onlyLocalNodePorts(t *testing.T, fp *Proxier, ipt *iptablestest.FakeIPTable
|
||||
svcPortName := proxy.ServicePortName{
|
||||
NamespacedName: makeNSN("ns1", "svc1"),
|
||||
Port: "p80",
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}
|
||||
|
||||
makeServiceMap(fp,
|
||||
@ -1022,8 +1032,9 @@ func onlyLocalNodePorts(t *testing.T, fp *Proxier, ipt *iptablestest.FakeIPTable
|
||||
NodeName: utilpointer.StringPtr(testHostname),
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -1363,10 +1374,11 @@ func makeNSN(namespace, name string) types.NamespacedName {
|
||||
return types.NamespacedName{Namespace: namespace, Name: name}
|
||||
}
|
||||
|
||||
func makeServicePortName(ns, name, port string) proxy.ServicePortName {
|
||||
func makeServicePortName(ns, name, port string, protocol v1.Protocol) proxy.ServicePortName {
|
||||
return proxy.ServicePortName{
|
||||
NamespacedName: makeNSN(ns, name),
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
}
|
||||
}
|
||||
|
||||
@ -1417,7 +1429,8 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Port: 11,
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1428,7 +1441,8 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Port: 11,
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1439,8 +1453,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1450,8 +1465,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1461,8 +1477,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11-2",
|
||||
Port: 11,
|
||||
Name: "p11-2",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1472,8 +1489,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 22,
|
||||
Name: "p11",
|
||||
Port: 22,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1486,11 +1504,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1500,16 +1520,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: "1.1.1.2",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1519,8 +1541,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -1528,8 +1551,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1540,19 +1564,22 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: "1.1.1.3",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1565,11 +1592,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -1579,11 +1608,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p14",
|
||||
Port: 14,
|
||||
Name: "p14",
|
||||
Port: 14,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1596,11 +1627,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p21",
|
||||
Port: 21,
|
||||
Name: "p21",
|
||||
Port: 21,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1610,8 +1643,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1625,8 +1659,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -1634,8 +1669,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p23",
|
||||
Port: 23,
|
||||
Name: "p23",
|
||||
Port: 23,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1649,8 +1685,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -1658,8 +1695,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p45",
|
||||
Port: 45,
|
||||
Name: "p45",
|
||||
Port: 45,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1671,19 +1709,22 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.11",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: "1.1.1.2",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p122",
|
||||
Port: 122,
|
||||
Name: "p122",
|
||||
Port: 122,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1693,8 +1734,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "3.3.3.3",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p33",
|
||||
Port: 33,
|
||||
Name: "p33",
|
||||
Port: 33,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1705,8 +1747,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -1738,12 +1781,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", unnamedPort),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
@ -1759,12 +1802,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
@ -1782,18 +1825,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", multipleSubsets),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
@ -1809,24 +1852,24 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsMultiplePortsLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
@ -1846,53 +1889,53 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns2", "ep2", multipleSubsetsIPsPorts2),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:13", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p14"): {
|
||||
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:14", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:14", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p21"): {
|
||||
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:21", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:21", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p22"): {
|
||||
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:22", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:13", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:13", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p14"): {
|
||||
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.3:14", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.4:14", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p21"): {
|
||||
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:21", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:21", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p22"): {
|
||||
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.1:22", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
||||
},
|
||||
@ -1913,13 +1956,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", ""): true,
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns1", "ep1"): 1,
|
||||
@ -1933,14 +1976,14 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.1:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", ""),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -1953,23 +1996,23 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortsLocalNoLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns1", "ep1"): 1,
|
||||
@ -1983,29 +2026,29 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:11", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:12", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.2:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "1.1.1.1:12",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "1.1.1.2:12",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2018,21 +2061,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsWithLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns1", "ep1"): 1,
|
||||
@ -2046,21 +2089,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.2:12",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2073,21 +2116,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortRenamed),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11-2"): {
|
||||
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.1:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p11-2"): true,
|
||||
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
}, {
|
||||
@ -2099,18 +2142,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortRenumbered),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:22", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.1:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2129,62 +2172,62 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns4", "ep4", complexAfter4),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p22"): {
|
||||
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.2:22", IsLocal: true}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.22:22", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p23"): {
|
||||
makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "2.2.2.3:23", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns4", "ep4", "p44"): {
|
||||
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.5:44", IsLocal: true}},
|
||||
},
|
||||
makeServicePortName("ns4", "ep4", "p45"): {
|
||||
makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.6:45", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.11:11", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:12", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p122"): {
|
||||
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.2:122", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns3", "ep3", "p33"): {
|
||||
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "3.3.3.3:33", IsLocal: false}},
|
||||
},
|
||||
makeServicePortName("ns4", "ep4", "p44"): {
|
||||
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "4.4.4.4:44", IsLocal: true}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "2.2.2.2:22",
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "2.2.2.22:22",
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "2.2.2.3:23",
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p23"),
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "4.4.4.5:44",
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p44"),
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "4.4.4.6:45",
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p45"),
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
||||
makeServicePortName("ns1", "ep1", "p122"): true,
|
||||
makeServicePortName("ns3", "ep3", "p33"): true,
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): true,
|
||||
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns4", "ep4"): 1,
|
||||
@ -2199,13 +2242,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*endpointsInfo{},
|
||||
expectedResult: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{BaseEndpointInfo: &proxy.BaseEndpointInfo{Endpoint: "1.1.1.1:11", IsLocal: false}},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", ""): true,
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
},
|
||||
@ -2285,29 +2328,6 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
// the shared EndpointChangeTracker and EndpointSliceCache. This test ensures that the
|
||||
// iptables proxier supports translating EndpointSlices to iptables output.
|
||||
func TestEndpointSliceE2E(t *testing.T) {
|
||||
expectedIPTablesWithoutSlice := `*filter
|
||||
:KUBE-SERVICES - [0:0]
|
||||
:KUBE-EXTERNAL-SERVICES - [0:0]
|
||||
:KUBE-FORWARD - [0:0]
|
||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: has no endpoints" -m -p -d 172.20.1.1/32 --dport 0 -j REJECT
|
||||
-A KUBE-FORWARD -m conntrack --ctstate INVALID -j DROP
|
||||
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding rules" -m mark --mark -j ACCEPT
|
||||
-A KUBE-FORWARD -s 10.0.0.0/24 -m comment --comment "kubernetes forwarding conntrack pod source rule" -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
||||
-A KUBE-FORWARD -m comment --comment "kubernetes forwarding conntrack pod destination rule" -d 10.0.0.0/24 -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
|
||||
COMMIT
|
||||
*nat
|
||||
:KUBE-SERVICES - [0:0]
|
||||
:KUBE-NODEPORTS - [0:0]
|
||||
:KUBE-POSTROUTING - [0:0]
|
||||
:KUBE-MARK-MASQ - [0:0]
|
||||
:KUBE-SVC-3WUAALNGPYZZAWAD - [0:0]
|
||||
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark -j MASQUERADE
|
||||
-A KUBE-MARK-MASQ -j MARK --set-xmark
|
||||
-X KUBE-SVC-3WUAALNGPYZZAWAD
|
||||
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
||||
COMMIT
|
||||
`
|
||||
|
||||
expectedIPTablesWithSlice := `*filter
|
||||
:KUBE-SERVICES - [0:0]
|
||||
:KUBE-EXTERNAL-SERVICES - [0:0]
|
||||
@ -2322,23 +2342,23 @@ COMMIT
|
||||
:KUBE-NODEPORTS - [0:0]
|
||||
:KUBE-POSTROUTING - [0:0]
|
||||
:KUBE-MARK-MASQ - [0:0]
|
||||
:KUBE-SVC-3WUAALNGPYZZAWAD - [0:0]
|
||||
: - [0:0]
|
||||
: - [0:0]
|
||||
: - [0:0]
|
||||
:KUBE-SVC-AHZNAGK3SCETOS2T - [0:0]
|
||||
:KUBE-SEP-PXD6POUVGD2I37UY - [0:0]
|
||||
:KUBE-SEP-SOKZUIT7SCEVIP33 - [0:0]
|
||||
:KUBE-SEP-WVE3FAB34S7NZGDJ - [0:0]
|
||||
-A KUBE-POSTROUTING -m comment --comment "kubernetes service traffic requiring SNAT" -m mark --mark -j MASQUERADE
|
||||
-A KUBE-MARK-MASQ -j MARK --set-xmark
|
||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m -p -d 172.20.1.1/32 --dport 0 ! -s 10.0.0.0/24 -j KUBE-MARK-MASQ
|
||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m -p -d 172.20.1.1/32 --dport 0 -j KUBE-SVC-3WUAALNGPYZZAWAD
|
||||
-A KUBE-SVC-3WUAALNGPYZZAWAD -m statistic --mode random --probability 0.33333 -j
|
||||
-A -s 10.0.1.1/32 -j KUBE-MARK-MASQ
|
||||
-A -m -p -j DNAT --to-destination 10.0.1.1:80
|
||||
-A KUBE-SVC-3WUAALNGPYZZAWAD -m statistic --mode random --probability 0.50000 -j
|
||||
-A -s 10.0.1.2/32 -j KUBE-MARK-MASQ
|
||||
-A -m -p -j DNAT --to-destination 10.0.1.2:80
|
||||
-A KUBE-SVC-3WUAALNGPYZZAWAD -j
|
||||
-A -s 10.0.1.3/32 -j KUBE-MARK-MASQ
|
||||
-A -m -p -j DNAT --to-destination 10.0.1.3:80
|
||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m tcp -p tcp -d 172.20.1.1/32 --dport 0 ! -s 10.0.0.0/24 -j KUBE-MARK-MASQ
|
||||
-A KUBE-SERVICES -m comment --comment "ns1/svc1: cluster IP" -m tcp -p tcp -d 172.20.1.1/32 --dport 0 -j KUBE-SVC-AHZNAGK3SCETOS2T
|
||||
-A KUBE-SVC-AHZNAGK3SCETOS2T -m statistic --mode random --probability 0.33333 -j KUBE-SEP-PXD6POUVGD2I37UY
|
||||
-A KUBE-SEP-PXD6POUVGD2I37UY -s 10.0.1.1/32 -j KUBE-MARK-MASQ
|
||||
-A KUBE-SEP-PXD6POUVGD2I37UY -m tcp -p tcp -j DNAT --to-destination 10.0.1.1:80
|
||||
-A KUBE-SVC-AHZNAGK3SCETOS2T -m statistic --mode random --probability 0.50000 -j KUBE-SEP-SOKZUIT7SCEVIP33
|
||||
-A KUBE-SEP-SOKZUIT7SCEVIP33 -s 10.0.1.2/32 -j KUBE-MARK-MASQ
|
||||
-A KUBE-SEP-SOKZUIT7SCEVIP33 -m tcp -p tcp -j DNAT --to-destination 10.0.1.2:80
|
||||
-A KUBE-SVC-AHZNAGK3SCETOS2T -j KUBE-SEP-WVE3FAB34S7NZGDJ
|
||||
-A KUBE-SEP-WVE3FAB34S7NZGDJ -s 10.0.1.3/32 -j KUBE-MARK-MASQ
|
||||
-A KUBE-SEP-WVE3FAB34S7NZGDJ -m tcp -p tcp -j DNAT --to-destination 10.0.1.3:80
|
||||
-A KUBE-SERVICES -m comment --comment "kubernetes service nodeports; NOTE: this must be the last rule in this chain" -m addrtype --dst-type LOCAL -j KUBE-NODEPORTS
|
||||
COMMIT
|
||||
`
|
||||
@ -2357,11 +2377,12 @@ COMMIT
|
||||
Spec: v1.ServiceSpec{
|
||||
ClusterIP: "172.20.1.1",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80)}},
|
||||
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}},
|
||||
},
|
||||
})
|
||||
|
||||
ipAddressType := discovery.AddressTypeIP
|
||||
tcpProtocol := v1.ProtocolTCP
|
||||
endpointSlice := &discovery.EndpointSlice{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fmt.Sprintf("%s-1", serviceName),
|
||||
@ -2369,8 +2390,9 @@ COMMIT
|
||||
Labels: map[string]string{discovery.LabelServiceName: serviceName},
|
||||
},
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
Protocol: &tcpProtocol,
|
||||
}},
|
||||
AddressType: &ipAddressType,
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
@ -2394,7 +2416,7 @@ COMMIT
|
||||
|
||||
fp.OnEndpointSliceDelete(endpointSlice)
|
||||
fp.syncProxyRules()
|
||||
assert.Equal(t, expectedIPTablesWithoutSlice, fp.iptablesData.String())
|
||||
assert.NotEqual(t, expectedIPTablesWithSlice, fp.iptablesData.String())
|
||||
}
|
||||
|
||||
// TODO(thockin): add *more* tests for syncProxyRules() or break it down further and test the pieces.
|
||||
|
@ -458,8 +458,9 @@ func TestNodePort(t *testing.T) {
|
||||
IP: "1002:ab8::2:10",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -575,8 +576,9 @@ func TestNodePort(t *testing.T) {
|
||||
IP: "10.180.0.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -726,8 +728,9 @@ func TestNodePort(t *testing.T) {
|
||||
IP: "10.180.0.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Protocol: v1.ProtocolSCTP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -1001,8 +1004,9 @@ func TestClusterIP(t *testing.T) {
|
||||
IP: "10.180.0.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Name: "p80",
|
||||
Port: int32(80),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -1012,8 +1016,9 @@ func TestClusterIP(t *testing.T) {
|
||||
IP: "1009:ab8::5:6",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p8080",
|
||||
Port: int32(8080),
|
||||
Name: "p8080",
|
||||
Port: int32(8080),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -1386,8 +1391,9 @@ func TestOnlyLocalNodePorts(t *testing.T) {
|
||||
NodeName: &thisHostname,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}}},
|
||||
{ // **remote** endpoint address, should not be added as RS
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -1395,8 +1401,9 @@ func TestOnlyLocalNodePorts(t *testing.T) {
|
||||
NodeName: &otherHostname,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -1483,8 +1490,9 @@ func TestLoadBalanceSourceRanges(t *testing.T) {
|
||||
NodeName: nil,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -1651,8 +1659,9 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
||||
NodeName: &thisHostname,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}}},
|
||||
{ // **remote** endpoint address, should not be added as RS
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -1660,8 +1669,9 @@ func TestOnlyLocalLoadBalancing(t *testing.T) {
|
||||
NodeName: &otherHostname,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Name: svcPortName.Port,
|
||||
Port: int32(svcPort),
|
||||
Protocol: v1.ProtocolTCP,
|
||||
}},
|
||||
}}
|
||||
}),
|
||||
@ -2030,10 +2040,11 @@ func TestSessionAffinity(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func makeServicePortName(ns, name, port string) proxy.ServicePortName {
|
||||
func makeServicePortName(ns, name, port string, protocol v1.Protocol) proxy.ServicePortName {
|
||||
return proxy.ServicePortName{
|
||||
NamespacedName: makeNSN(ns, name),
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
}
|
||||
}
|
||||
|
||||
@ -2049,7 +2060,8 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Port: 11,
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2060,7 +2072,8 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Port: 11,
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2071,8 +2084,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2082,8 +2096,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2093,8 +2108,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11-2",
|
||||
Port: 11,
|
||||
Name: "p11-2",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2104,8 +2120,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 22,
|
||||
Name: "p11",
|
||||
Port: 22,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2118,11 +2135,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2132,16 +2151,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: "1.1.1.2",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2151,8 +2172,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -2160,8 +2182,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2172,19 +2195,22 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: "1.1.1.3",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2197,11 +2223,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -2211,11 +2239,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Name: "p13",
|
||||
Port: 13,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p14",
|
||||
Port: 14,
|
||||
Name: "p14",
|
||||
Port: 14,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2228,11 +2258,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p21",
|
||||
Port: 21,
|
||||
Name: "p21",
|
||||
Port: 21,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2242,8 +2274,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.1",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2257,8 +2290,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Name: "p22",
|
||||
Port: 22,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -2266,8 +2300,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p23",
|
||||
Port: 23,
|
||||
Name: "p23",
|
||||
Port: 23,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2281,8 +2316,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
@ -2290,8 +2326,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p45",
|
||||
Port: 45,
|
||||
Name: "p45",
|
||||
Port: 45,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2303,19 +2340,22 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "1.1.1.11",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Name: "p11",
|
||||
Port: 11,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}, {
|
||||
Addresses: []v1.EndpointAddress{{
|
||||
IP: "1.1.1.2",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Name: "p12",
|
||||
Port: 12,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}, {
|
||||
Name: "p122",
|
||||
Port: 122,
|
||||
Name: "p122",
|
||||
Port: 122,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2325,8 +2365,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
IP: "3.3.3.3",
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p33",
|
||||
Port: 33,
|
||||
Name: "p33",
|
||||
Port: 33,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2337,8 +2378,9 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
NodeName: &nodeName,
|
||||
}},
|
||||
Ports: []v1.EndpointPort{{
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Name: "p44",
|
||||
Port: 44,
|
||||
Protocol: v1.ProtocolUDP,
|
||||
}},
|
||||
}}
|
||||
}
|
||||
@ -2370,12 +2412,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", unnamedPort),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
@ -2391,12 +2433,12 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||
},
|
||||
},
|
||||
@ -2414,18 +2456,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", multipleSubsets),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||
},
|
||||
},
|
||||
@ -2441,24 +2483,24 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsMultiplePortsLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:12", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:12", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||
},
|
||||
},
|
||||
@ -2478,53 +2520,53 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns2", "ep2", multipleSubsetsIPsPorts2),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||
{Endpoint: "1.1.1.4:13", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p14"): {
|
||||
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.3:14", IsLocal: false},
|
||||
{Endpoint: "1.1.1.4:14", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p21"): {
|
||||
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||
{Endpoint: "2.2.2.1:21", IsLocal: false},
|
||||
{Endpoint: "2.2.2.2:21", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p22"): {
|
||||
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||
{Endpoint: "2.2.2.1:22", IsLocal: false},
|
||||
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p13"): {
|
||||
makeServicePortName("ns1", "ep1", "p13", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.3:13", IsLocal: false},
|
||||
{Endpoint: "1.1.1.4:13", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p14"): {
|
||||
makeServicePortName("ns1", "ep1", "p14", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.3:14", IsLocal: false},
|
||||
{Endpoint: "1.1.1.4:14", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p21"): {
|
||||
makeServicePortName("ns2", "ep2", "p21", v1.ProtocolUDP): {
|
||||
{Endpoint: "2.2.2.1:21", IsLocal: false},
|
||||
{Endpoint: "2.2.2.2:21", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p22"): {
|
||||
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||
{Endpoint: "2.2.2.1:22", IsLocal: false},
|
||||
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
||||
},
|
||||
@ -2545,13 +2587,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", ""): true,
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns1", "ep1"): 1,
|
||||
@ -2565,14 +2607,14 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
nil,
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.1:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", ""),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2585,23 +2627,23 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortsLocalNoLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns1", "ep1"): 1,
|
||||
@ -2615,29 +2657,29 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:11", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:12", IsLocal: false},
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.2:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "1.1.1.1:12",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "1.1.1.2:12",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2650,21 +2692,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", multipleSubsetsWithLocal),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns1", "ep1"): 1,
|
||||
@ -2678,21 +2720,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPort),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.2:12",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2705,21 +2747,21 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortRenamed),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11-2"): {
|
||||
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.1:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p11-2"): true,
|
||||
makeServicePortName("ns1", "ep1", "p11-2", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
}, {
|
||||
@ -2731,18 +2773,18 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns1", "ep1", namedPortRenumbered),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:22", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "1.1.1.1:11",
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11"),
|
||||
ServicePortName: makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
@ -2761,62 +2803,62 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
makeTestEndpoints("ns4", "ep4", complexAfter4),
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p22"): {
|
||||
makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP): {
|
||||
{Endpoint: "2.2.2.2:22", IsLocal: true},
|
||||
{Endpoint: "2.2.2.22:22", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns2", "ep2", "p23"): {
|
||||
makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP): {
|
||||
{Endpoint: "2.2.2.3:23", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns4", "ep4", "p44"): {
|
||||
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||
{Endpoint: "4.4.4.4:44", IsLocal: true},
|
||||
{Endpoint: "4.4.4.5:44", IsLocal: true},
|
||||
},
|
||||
makeServicePortName("ns4", "ep4", "p45"): {
|
||||
makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP): {
|
||||
{Endpoint: "4.4.4.6:45", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
makeServicePortName("ns1", "ep1", "p11", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
{Endpoint: "1.1.1.11:11", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p12"): {
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.2:12", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns1", "ep1", "p122"): {
|
||||
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.2:122", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns3", "ep3", "p33"): {
|
||||
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): {
|
||||
{Endpoint: "3.3.3.3:33", IsLocal: false},
|
||||
},
|
||||
makeServicePortName("ns4", "ep4", "p44"): {
|
||||
makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP): {
|
||||
{Endpoint: "4.4.4.4:44", IsLocal: true},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{{
|
||||
Endpoint: "2.2.2.2:22",
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "2.2.2.22:22",
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22"),
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p22", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "2.2.2.3:23",
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p23"),
|
||||
ServicePortName: makeServicePortName("ns2", "ep2", "p23", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "4.4.4.5:44",
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p44"),
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p44", v1.ProtocolUDP),
|
||||
}, {
|
||||
Endpoint: "4.4.4.6:45",
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p45"),
|
||||
ServicePortName: makeServicePortName("ns4", "ep4", "p45", v1.ProtocolUDP),
|
||||
}},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", "p12"): true,
|
||||
makeServicePortName("ns1", "ep1", "p122"): true,
|
||||
makeServicePortName("ns3", "ep3", "p33"): true,
|
||||
makeServicePortName("ns1", "ep1", "p12", v1.ProtocolUDP): true,
|
||||
makeServicePortName("ns1", "ep1", "p122", v1.ProtocolUDP): true,
|
||||
makeServicePortName("ns3", "ep3", "p33", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{
|
||||
makeNSN("ns4", "ep4"): 1,
|
||||
@ -2831,13 +2873,13 @@ func Test_updateEndpointsMap(t *testing.T) {
|
||||
},
|
||||
oldEndpoints: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{},
|
||||
expectedResult: map[proxy.ServicePortName][]*proxy.BaseEndpointInfo{
|
||||
makeServicePortName("ns1", "ep1", ""): {
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): {
|
||||
{Endpoint: "1.1.1.1:11", IsLocal: false},
|
||||
},
|
||||
},
|
||||
expectedStaleEndpoints: []proxy.ServiceEndpoint{},
|
||||
expectedStaleServiceNames: map[proxy.ServicePortName]bool{
|
||||
makeServicePortName("ns1", "ep1", ""): true,
|
||||
makeServicePortName("ns1", "ep1", "", v1.ProtocolUDP): true,
|
||||
},
|
||||
expectedHealthchecks: map[types.NamespacedName]int{},
|
||||
},
|
||||
@ -3687,12 +3729,13 @@ func TestEndpointSliceE2E(t *testing.T) {
|
||||
Spec: v1.ServiceSpec{
|
||||
ClusterIP: "172.20.1.1",
|
||||
Selector: map[string]string{"foo": "bar"},
|
||||
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80)}},
|
||||
Ports: []v1.ServicePort{{Name: "", TargetPort: intstr.FromInt(80), Protocol: v1.ProtocolTCP}},
|
||||
},
|
||||
})
|
||||
|
||||
// Add initial endpoint slice
|
||||
ipAddressType := discovery.AddressTypeIP
|
||||
tcpProtocol := v1.ProtocolTCP
|
||||
endpointSlice := &discovery.EndpointSlice{
|
||||
ObjectMeta: metav1.ObjectMeta{
|
||||
Name: fmt.Sprintf("%s-1", serviceName),
|
||||
@ -3700,8 +3743,9 @@ func TestEndpointSliceE2E(t *testing.T) {
|
||||
Labels: map[string]string{discovery.LabelServiceName: serviceName},
|
||||
},
|
||||
Ports: []discovery.EndpointPort{{
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
Name: utilpointer.StringPtr(""),
|
||||
Port: utilpointer.Int32Ptr(80),
|
||||
Protocol: &tcpProtocol,
|
||||
}},
|
||||
AddressType: &ipAddressType,
|
||||
Endpoints: []discovery.Endpoint{{
|
||||
|
@ -299,7 +299,7 @@ func (sct *ServiceChangeTracker) serviceToServiceMap(service *v1.Service) Servic
|
||||
serviceMap := make(ServiceMap)
|
||||
for i := range service.Spec.Ports {
|
||||
servicePort := &service.Spec.Ports[i]
|
||||
svcPortName := ServicePortName{NamespacedName: svcName, Port: servicePort.Name}
|
||||
svcPortName := ServicePortName{NamespacedName: svcName, Port: servicePort.Name, Protocol: servicePort.Protocol}
|
||||
baseSvcInfo := sct.newBaseServiceInfo(servicePort, service)
|
||||
if sct.makeServiceInfo != nil {
|
||||
serviceMap[svcPortName] = sct.makeServiceInfo(servicePort, service, baseSvcInfo)
|
||||
|
@ -75,10 +75,11 @@ func makeNSN(namespace, name string) types.NamespacedName {
|
||||
return types.NamespacedName{Namespace: namespace, Name: name}
|
||||
}
|
||||
|
||||
func makeServicePortName(ns, name, port string) ServicePortName {
|
||||
func makeServicePortName(ns, name, port string, protocol v1.Protocol) ServicePortName {
|
||||
return ServicePortName{
|
||||
NamespacedName: makeNSN(ns, name),
|
||||
Port: port,
|
||||
Protocol: protocol,
|
||||
}
|
||||
}
|
||||
|
||||
@ -140,8 +141,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "p2", "UDP", 1235, 5321, 0)
|
||||
}),
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("ns2", "cluster-ip", "p1"): makeTestServiceInfo("172.16.55.4", 1234, "UDP", 0),
|
||||
makeServicePortName("ns2", "cluster-ip", "p2"): makeTestServiceInfo("172.16.55.4", 1235, "UDP", 0),
|
||||
makeServicePortName("ns2", "cluster-ip", "p1", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.4", 1234, "UDP", 0),
|
||||
makeServicePortName("ns2", "cluster-ip", "p2", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.4", 1235, "UDP", 0),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -153,8 +154,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
svc.Spec.Ports = addTestPort(svc.Spec.Ports, "port2", "TCP", 344, 677, 0)
|
||||
}),
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("ns2", "node-port", "port1"): makeTestServiceInfo("172.16.55.10", 345, "UDP", 0),
|
||||
makeServicePortName("ns2", "node-port", "port2"): makeTestServiceInfo("172.16.55.10", 344, "TCP", 0),
|
||||
makeServicePortName("ns2", "node-port", "port1", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.10", 345, "UDP", 0),
|
||||
makeServicePortName("ns2", "node-port", "port2", v1.ProtocolTCP): makeTestServiceInfo("172.16.55.10", 344, "TCP", 0),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -172,8 +173,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
}
|
||||
}),
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("ns1", "load-balancer", "port3"): makeTestServiceInfo("172.16.55.11", 8675, "UDP", 0),
|
||||
makeServicePortName("ns1", "load-balancer", "port4"): makeTestServiceInfo("172.16.55.11", 8676, "UDP", 0),
|
||||
makeServicePortName("ns1", "load-balancer", "port3", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.11", 8675, "UDP", 0),
|
||||
makeServicePortName("ns1", "load-balancer", "port4", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.11", 8676, "UDP", 0),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -193,8 +194,8 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
svc.Spec.HealthCheckNodePort = 345
|
||||
}),
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("ns1", "only-local-load-balancer", "portx"): makeTestServiceInfo("172.16.55.12", 8677, "UDP", 345),
|
||||
makeServicePortName("ns1", "only-local-load-balancer", "porty"): makeTestServiceInfo("172.16.55.12", 8678, "UDP", 345),
|
||||
makeServicePortName("ns1", "only-local-load-balancer", "portx", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.12", 8677, "UDP", 345),
|
||||
makeServicePortName("ns1", "only-local-load-balancer", "porty", v1.ProtocolUDP): makeTestServiceInfo("172.16.55.12", 8678, "UDP", 345),
|
||||
},
|
||||
},
|
||||
{
|
||||
@ -268,7 +269,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("test", "validIPv4", "testPort"): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
makeServicePortName("test", "validIPv4", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
info.externalIPs = []string{testExternalIPv4}
|
||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv4}
|
||||
}),
|
||||
@ -296,7 +297,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("test", "validIPv6", "testPort"): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
makeServicePortName("test", "validIPv6", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
info.externalIPs = []string{testExternalIPv6}
|
||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv6}
|
||||
}),
|
||||
@ -324,7 +325,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("test", "filterIPv6InIPV4Mode", "testPort"): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
makeServicePortName("test", "filterIPv6InIPV4Mode", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv4, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
info.externalIPs = []string{testExternalIPv4}
|
||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv4}
|
||||
}),
|
||||
@ -352,7 +353,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
},
|
||||
},
|
||||
expected: map[ServicePortName]*BaseServiceInfo{
|
||||
makeServicePortName("test", "filterIPv4InIPV6Mode", "testPort"): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
makeServicePortName("test", "filterIPv4InIPV6Mode", "testPort", v1.ProtocolTCP): makeTestServiceInfo(testClusterIPv6, 12345, "TCP", 0, func(info *BaseServiceInfo) {
|
||||
info.externalIPs = []string{testExternalIPv6}
|
||||
info.loadBalancerSourceRanges = []string{testSourceRangeIPv6}
|
||||
}),
|
||||
@ -370,7 +371,7 @@ func TestServiceToServiceMap(t *testing.T) {
|
||||
t.Errorf("[%s] expected %d new, got %d: %v", tc.desc, len(tc.expected), len(newServices), spew.Sdump(newServices))
|
||||
}
|
||||
for svcKey, expectedInfo := range tc.expected {
|
||||
svcInfo := newServices[svcKey].(*BaseServiceInfo)
|
||||
svcInfo, _ := newServices[svcKey].(*BaseServiceInfo)
|
||||
if !svcInfo.clusterIP.Equal(expectedInfo.clusterIP) ||
|
||||
svcInfo.port != expectedInfo.port ||
|
||||
svcInfo.protocol != expectedInfo.protocol ||
|
||||
|
@ -43,7 +43,8 @@ type Provider interface {
|
||||
// identifier for a load-balanced service.
|
||||
type ServicePortName struct {
|
||||
types.NamespacedName
|
||||
Port string
|
||||
Port string
|
||||
Protocol v1.Protocol
|
||||
}
|
||||
|
||||
func (spn ServicePortName) String() string {
|
||||
|
Loading…
Reference in New Issue
Block a user