mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 19:31:44 +00:00
Merge pull request #88417 from aramase/conformance-nodeport
check ip family for node port connectivity test
This commit is contained in:
commit
9a8e869590
@ -764,9 +764,11 @@ func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod
|
|||||||
return nil
|
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)
|
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
|
||||||
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
|
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
|
||||||
|
isClusterIPV4 := net.ParseIP(clusterIP).To4() != nil
|
||||||
|
|
||||||
for _, internalAddr := range internalAddrs {
|
for _, internalAddr := range internalAddrs {
|
||||||
// If the node's internal address points to localhost, then we are not
|
// If the node's internal address points to localhost, then we are not
|
||||||
// able to test the service reachability via that address
|
// 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)
|
framework.Logf("skipping testEndpointReachability() for internal adddress %s", internalAddr)
|
||||||
continue
|
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)
|
err := testEndpointReachability(internalAddr, sp.NodePort, sp.Protocol, pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, externalAddr := range externalAddrs {
|
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)
|
err := testEndpointReachability(externalAddr, sp.NodePort, sp.Protocol, pod)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -879,7 +894,7 @@ func (j *TestJig) checkNodePortServiceReachability(svc *v1.Service, pod *v1.Pod)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
err = testReachabilityOverNodePorts(nodes, servicePort, pod)
|
err = testReachabilityOverNodePorts(nodes, servicePort, pod, clusterIP)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user