mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-28 14:07:14 +00:00
Fix node port service reachability test for nodes running on localhost
If a node's internal address points to 127.0.0.1, then we skip the node port reachability test. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
parent
6d49d69c91
commit
715627d95e
@ -769,10 +769,17 @@ func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod
|
||||
testEndpointReachability(clusterIP, sp.Port, sp.Protocol, execPod)
|
||||
}
|
||||
}
|
||||
|
||||
func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v1.Pod) {
|
||||
internalAddrs := e2enode.CollectAddresses(nodes, v1.NodeInternalIP)
|
||||
externalAddrs := e2enode.CollectAddresses(nodes, v1.NodeExternalIP)
|
||||
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
|
||||
if isInvalidOrLocalhostAddress(internalAddr) {
|
||||
e2elog.Logf("skipping testEndpointReachability() for internal adddress %s", internalAddr)
|
||||
continue
|
||||
}
|
||||
testEndpointReachability(internalAddr, sp.NodePort, sp.Protocol, pod)
|
||||
}
|
||||
for _, externalAddr := range externalAddrs {
|
||||
@ -780,6 +787,16 @@ func testReachabilityOverNodePorts(nodes *v1.NodeList, sp v1.ServicePort, pod *v
|
||||
}
|
||||
}
|
||||
|
||||
// isInvalidOrLocalhostAddress returns `true` if the provided `ip` is either not
|
||||
// parsable or the loopback address. Otherwise it will return `false`.
|
||||
func isInvalidOrLocalhostAddress(ip string) bool {
|
||||
parsedIP := net.ParseIP(ip)
|
||||
if parsedIP == nil || parsedIP.IsLoopback() {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// testEndpointReachability tests reachability to endpoints (i.e. IP, ServiceName) and ports. Test request is initiated from specified execPod.
|
||||
// TCP and UDP protocol based service are supported at this moment
|
||||
// TODO: add support to test SCTP Protocol based services.
|
||||
|
Loading…
Reference in New Issue
Block a user