mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Merge pull request #120104 from togettoyou/cleanup_endpoints
cleanup: Refactor BaseEndpointInfo to cache IP and Port values
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user