Merge pull request #88417 from aramase/conformance-nodeport

check ip family for node port connectivity test
This commit is contained in:
Kubernetes Prow Robot 2020-02-21 22:30:56 -08:00 committed by GitHub
commit 9a8e869590
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -764,9 +764,11 @@ func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod
return nil
}
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod) error {
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod, clusterIP string) error {
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
isClusterIPV4 := net.ParseIP(clusterIP).To4() != nil
for _, internalAddr := range internalAddrs {
// If the node's internal address points to localhost, then we are not
// able to test the service reachability via that address
@ -774,12 +776,25 @@ func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v
framework.Logf("skipping testEndpointReachability() for internal adddress %s", internalAddr)
continue
}
isNodeInternalIPV4 := net.ParseIP(internalAddr).To4() != nil
// Check service reachability on the node internalIP which is same family
// as clusterIP
if isClusterIPV4 != isNodeInternalIPV4 {
framework.Logf("skipping testEndpointReachability() for internal adddress %s as it does not match clusterIP (%s) family", internalAddr, clusterIP)
continue
}
err := testEndpointReachability(internalAddr, sp.NodePort, sp.Protocol, pod)
if err != nil {
return err
}
}
for _, externalAddr := range externalAddrs {
isNodeExternalIPV4 := net.ParseIP(externalAddr).To4() != nil
if isClusterIPV4 != isNodeExternalIPV4 {
framework.Logf("skipping testEndpointReachability() for external adddress %s as it does not match clusterIP (%s) family", externalAddr, clusterIP)
continue
}
err := testEndpointReachability(externalAddr, sp.NodePort, sp.Protocol, pod)
if err != nil {
return err
@ -879,7 +894,7 @@ func (j *TestJig) checkNodePortServiceReachability(svc *v1.Service, pod *v1.Pod)
if err != nil {
return err
}
err = testReachabilityOverNodePorts(nodes, servicePort, pod)
err = testReachabilityOverNodePorts(nodes, servicePort, pod, clusterIP)
if err != nil {
return err
}