@@ -764,22 +764,37 @@ func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod
764
764
return nil
765
765
}
766
766
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 {
768
768
internalAddrs := e2enode .CollectAddresses (nodes , v1 .NodeInternalIP )
769
769
externalAddrs := e2enode .CollectAddresses (nodes , v1 .NodeExternalIP )
770
+ isClusterIPV4 := net .ParseIP (clusterIP ).To4 () != nil
771
+
770
772
for _ , internalAddr := range internalAddrs {
771
773
// If the node's internal address points to localhost, then we are not
772
774
// able to test the service reachability via that address
773
775
if isInvalidOrLocalhostAddress (internalAddr ) {
774
776
framework .Logf ("skipping testEndpointReachability() for internal adddress %s" , internalAddr )
775
777
continue
776
778
}
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
+
777
787
err := testEndpointReachability (internalAddr , sp .NodePort , sp .Protocol , pod )
778
788
if err != nil {
779
789
return err
780
790
}
781
791
}
782
792
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
+ }
783
798
err := testEndpointReachability (externalAddr , sp .NodePort , sp .Protocol , pod )
784
799
if err != nil {
785
800
return err
@@ -879,7 +894,7 @@ func (j *TestJig) checkNodePortServiceReachability(svc *v1.Service, pod *v1.Pod)
879
894
if err != nil {
880
895
return err
881
896
}
882
- err = testReachabilityOverNodePorts (nodes , servicePort , pod )
897
+ err = testReachabilityOverNodePorts (nodes , servicePort , pod , clusterIP )
883
898
if err != nil {
884
899
return err
885
900
}
0 commit comments