dualstack: use correct IPFamily list for conntrack checks in e2e

We hardcode the index number in the KubeProxy/Conntrack e2es and
CollectAddresses returns 4 mixed IP Family addresses in a dualstack
cluster. This change ensures that the serverNodeInfo.nodeIP has only
valid addresses for the expected IPFamily per test case.

Signed-off-by: Christopher M. Luciano <cmluciano@us.ibm.com>
This commit is contained in:
Christopher M. Luciano
2020-11-02 14:55:24 -05:00
parent 17dcccbe07
commit fa7a802d55
4 changed files with 45 additions and 5 deletions

View File

@@ -20,6 +20,7 @@ import (
"context"
"encoding/json"
"fmt"
netutil "k8s.io/utils/net"
"net"
"strings"
"time"
@@ -248,6 +249,26 @@ func GetInternalIP(node *v1.Node) (string, error) {
return host, nil
}
// GetAddressesByTypeAndFamily returns a list of addresses of the given addressType for the given node
// and filtered by IPFamily
func GetAddressesByTypeAndFamily(node *v1.Node, addressType v1.NodeAddressType, family v1.IPFamily) (ips []string) {
for _, nodeAddress := range node.Status.Addresses {
if nodeAddress.Type != addressType {
continue
}
if nodeAddress.Address == "" {
continue
}
if family == v1.IPv6Protocol && netutil.IsIPv6String(nodeAddress.Address) {
ips = append(ips, nodeAddress.Address)
}
if family == v1.IPv4Protocol && !netutil.IsIPv6String(nodeAddress.Address) {
ips = append(ips, nodeAddress.Address)
}
}
return
}
// GetAddresses returns a list of addresses of the given addressType for the given node
func GetAddresses(node *v1.Node, addressType v1.NodeAddressType) (ips []string) {
for j := range node.Status.Addresses {