Skip to content

Commit 9a8e869

Browse files
authored
Merge pull request kubernetes#88417 from aramase/conformance-nodeport
check ip family for node port connectivity test
2 parents f2e5ef6 + c811fc5 commit 9a8e869

File tree

1 file changed

+17
-2
lines changed
  • test/e2e/framework/service

1 file changed

+17
-2
lines changed

test/e2e/framework/service/jig.go

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -764,22 +764,37 @@ func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod
764764
return nil
765765
}
766766

767-
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod) error {
767+
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod, clusterIP string) error {
768768
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
769769
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
770+
isClusterIPV4 := net.ParseIP(clusterIP).To4() != nil
771+
770772
for _, internalAddr := range internalAddrs {
771773
// If the node's internal address points to localhost, then we are not
772774
// able to test the service reachability via that address
773775
if isInvalidOrLocalhostAddress(internalAddr) {
774776
framework.Logf("skipping testEndpointReachability() for internal adddress %s", internalAddr)
775777
continue
776778
}
779+
isNodeInternalIPV4 := net.ParseIP(internalAddr).To4() != nil
780+
// Check service reachability on the node internalIP which is same family
781+
// as clusterIP
782+
if isClusterIPV4 != isNodeInternalIPV4 {
783+
framework.Logf("skipping testEndpointReachability() for internal adddress %s as it does not match clusterIP (%s) family", internalAddr, clusterIP)
784+
continue
785+
}
786+
777787
err := testEndpointReachability(internalAddr, sp.NodePort, sp.Protocol, pod)
778788
if err != nil {
779789
return err
780790
}
781791
}
782792
for _, externalAddr := range externalAddrs {
793+
isNodeExternalIPV4 := net.ParseIP(externalAddr).To4() != nil
794+
if isClusterIPV4 != isNodeExternalIPV4 {
795+
framework.Logf("skipping testEndpointReachability() for external adddress %s as it does not match clusterIP (%s) family", externalAddr, clusterIP)
796+
continue
797+
}
783798
err := testEndpointReachability(externalAddr, sp.NodePort, sp.Protocol, pod)
784799
if err != nil {
785800
return err
@@ -879,7 +894,7 @@ func (j *TestJig) checkNodePortServiceReachability(svc *v1.Service, pod *v1.Pod)
879894
if err != nil {
880895
return err
881896
}
882-
err = testReachabilityOverNodePorts(nodes, servicePort, pod)
897+
err = testReachabilityOverNodePorts(nodes, servicePort, pod, clusterIP)
883898
if err != nil {
884899
return err
885900
}

0 commit comments

Comments
 (0)