diff --git a/test/e2e/framework/networking_utils.go b/test/e2e/framework/networking_utils.go index 72e34262350..f2e31c8197f 100644 --- a/test/e2e/framework/networking_utils.go +++ b/test/e2e/framework/networking_utils.go @@ -40,7 +40,6 @@ import ( e2enode "k8s.io/kubernetes/test/e2e/framework/node" e2epod "k8s.io/kubernetes/test/e2e/framework/pod" imageutils "k8s.io/kubernetes/test/utils/image" - k8utilnet "k8s.io/utils/net" ) const ( @@ -76,16 +75,6 @@ const ( // NetexecImageName is the image name for agnhost. var NetexecImageName = imageutils.GetE2EImage(imageutils.Agnhost) -// TranslateIPv4ToIPv6 maps an IPv4 address into a valid IPv6 address -// adding the well known prefix "0::ffff:" https://tools.ietf.org/html/rfc2765 -// if the ip is IPv4 and the cluster IPFamily is IPv6, otherwise returns the same ip -func TranslateIPv4ToIPv6(ip string) string { - if TestContext.IPFamily == "ipv6" && !k8utilnet.IsIPv6String(ip) && ip != "" { - ip = "0::ffff:" + ip - } - return ip -} - // NewNetworkingTestConfig creates and sets up a new test config helper. func NewNetworkingTestConfig(f *Framework) *NetworkingTestConfig { config := &NetworkingTestConfig{f: f, Namespace: f.Namespace.Name, HostNetwork: true} diff --git a/test/e2e/scheduling/BUILD b/test/e2e/scheduling/BUILD index 7a7bdf920bf..ef83680617b 100644 --- a/test/e2e/scheduling/BUILD +++ b/test/e2e/scheduling/BUILD @@ -55,6 +55,7 @@ go_library( "//vendor/github.com/onsi/gomega:go_default_library", "//vendor/github.com/stretchr/testify/assert:go_default_library", "//vendor/google.golang.org/api/compute/v1:go_default_library", + "//vendor/k8s.io/utils/net:go_default_library", ], ) diff --git a/test/e2e/scheduling/predicates.go b/test/e2e/scheduling/predicates.go index 231f06a11e0..57aaa9395d4 100644 --- a/test/e2e/scheduling/predicates.go +++ b/test/e2e/scheduling/predicates.go @@ -34,6 +34,7 @@ import ( e2epod "k8s.io/kubernetes/test/e2e/framework/pod" testutils "k8s.io/kubernetes/test/utils" imageutils "k8s.io/kubernetes/test/utils/image" + k8utilnet "k8s.io/utils/net" "github.com/onsi/ginkgo" @@ -810,7 +811,7 @@ func CreateNodeSelectorPods(f *framework.Framework, id string, replicas int, nod // create pod which using hostport on the specified node according to the nodeSelector func createHostPortPodOnNode(f *framework.Framework, podName, ns, hostIP string, port int32, protocol v1.Protocol, nodeSelector map[string]string, expectScheduled bool) { - hostIP = framework.TranslateIPv4ToIPv6(hostIP) + hostIP = translateIPv4ToIPv6(hostIP) createPausePod(f, pausePodConfig{ Name: podName, Ports: []v1.ContainerPort{ @@ -829,3 +830,13 @@ func createHostPortPodOnNode(f *framework.Framework, podName, ns, hostIP string, framework.ExpectNoError(err) } } + +// translateIPv4ToIPv6 maps an IPv4 address into a valid IPv6 address +// adding the well known prefix "0::ffff:" https://tools.ietf.org/html/rfc2765 +// if the ip is IPv4 and the cluster IPFamily is IPv6, otherwise returns the same ip +func translateIPv4ToIPv6(ip string) string { + if framework.TestContext.IPFamily == "ipv6" && !k8utilnet.IsIPv6String(ip) && ip != "" { + ip = "0::ffff:" + ip + } + return ip +}