fix ipvs proxier getLocalIPs() error
This commit is contained in:
@@ -798,7 +798,7 @@ func getLocalIPs(endpointsMap proxyEndpointsMap) map[types.NamespacedName]sets.S
|
||||
for svcPortName := range endpointsMap {
|
||||
for _, ep := range endpointsMap[svcPortName] {
|
||||
if ep.isLocal {
|
||||
// If the endpoint has a bad format, ipPart() will log an
|
||||
// If the endpoint has a bad format, utilproxy.IPPart() will log an
|
||||
// error and ep.IPPart() will return a null string.
|
||||
if ip := ep.IPPart(); ip != "" {
|
||||
nsn := svcPortName.NamespacedName
|
||||
|
@@ -1264,6 +1264,14 @@ func Test_getLocalIPs(t *testing.T) {
|
||||
{Namespace: "ns2", Name: "ep2"}: sets.NewString("2.2.2.2", "2.2.2.22", "2.2.2.3"),
|
||||
{Namespace: "ns4", Name: "ep4"}: sets.NewString("4.4.4.4", "4.4.4.6"),
|
||||
},
|
||||
}, {
|
||||
// Case[5]: named port local and bad endpoints IP
|
||||
endpointsMap: map[proxy.ServicePortName][]*endpointsInfo{
|
||||
makeServicePortName("ns1", "ep1", "p11"): {
|
||||
{endpoint: "bad ip:11", isLocal: true},
|
||||
},
|
||||
},
|
||||
expected: map[types.NamespacedName]sets.String{},
|
||||
}}
|
||||
|
||||
for tci, tc := range testCases {
|
||||
|
Reference in New Issue
Block a user