Skip to content

Commit

Permalink
specify source address for loopback destination in IPv6
Browse files Browse the repository at this point in the history
  • Loading branch information
Antonio Ojea committed Nov 17, 2020
1 parent 57fb18e commit 2b540f7
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions test/e2e/scheduling/predicates.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,11 +662,11 @@ var _ = SIGDescribe("SchedulerPredicates [Serial]", func() {
framework.ConformanceIt("validates that there is no conflict between pods with same hostPort but different hostIP and protocol", func() {

nodeName := GetNodeThatCanRunPod(f)
hostIP1 := getNodeHostIP(f, nodeName)
hostIP2 := "127.0.0.1"
hostIP1 := "127.0.0.1"
if framework.TestContext.ClusterIsIPv6() {
hostIP2 = "::1"
hostIP1 = "::1"
}
hostIP2 := getNodeHostIP(f, nodeName)

// use nodeSelector to make sure the testing pods get assigned on the same node to explicitly verify there exists conflict or not
ginkgo.By("Trying to apply a random label on the found node.")
Expand Down Expand Up @@ -712,7 +712,8 @@ var _ = SIGDescribe("SchedulerPredicates [Serial]", func() {

// poll each host port from the same host, we try 5 times
timeout := 5
cmdPod1 := []string{"/bin/sh", "-c", fmt.Sprintf("curl -g --connect-timeout %v http://%s/hostname", timeout, net.JoinHostPort(hostIP1, strconv.Itoa(int(port))))}
// HostIP1 is a loopback address and IPv6 doesn't NAT from localhost -> localhost, it doesn't have the route_localnet kernel hack, so we specify the source IP
cmdPod1 := []string{"/bin/sh", "-c", fmt.Sprintf("curl -g --connect-timeout %v --interface %s http://%s/hostname", timeout, hostIP2, net.JoinHostPort(hostIP1, strconv.Itoa(int(port))))}
cmdPod2 := []string{"/bin/sh", "-c", fmt.Sprintf("curl -g --connect-timeout %v http://%s/hostname", timeout, net.JoinHostPort(hostIP2, strconv.Itoa(int(port))))}
cmdPod3 := []string{"/bin/sh", "-c", fmt.Sprintf("nc -vuz -w %v %s %d", timeout, hostIP2, port)}
success := false
Expand Down

0 comments on commit 2b540f7

Please sign in to comment.