kube-proxy: store ExternalIPs as net.IP

They were stored as strings which could be non-canonical
and cause problems
This commit is contained in:
Lars Ekman
2024-01-07 10:48:39 +01:00
parent d2294007b0
commit 9eac24c656
8 changed files with 47 additions and 41 deletions

View File

@@ -338,10 +338,18 @@ func TestMapIPsByIPFamily(t *testing.T) {
ipMap := MapIPsByIPFamily(testcase.ipString)
if !reflect.DeepEqual(testcase.expectCorrect, ipMap[ipFamily]) {
var ipStr []string
for _, ip := range ipMap[ipFamily] {
ipStr = append(ipStr, ip.String())
}
if !reflect.DeepEqual(testcase.expectCorrect, ipStr) {
t.Errorf("Test %v failed: expected %v, got %v", testcase.desc, testcase.expectCorrect, ipMap[ipFamily])
}
if !reflect.DeepEqual(testcase.expectIncorrect, ipMap[otherIPFamily]) {
ipStr = nil
for _, ip := range ipMap[otherIPFamily] {
ipStr = append(ipStr, ip.String())
}
if !reflect.DeepEqual(testcase.expectIncorrect, ipStr) {
t.Errorf("Test %v failed: expected %v, got %v", testcase.desc, testcase.expectIncorrect, ipMap[otherIPFamily])
}
})