mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 19:01:49 +00:00
simplify clusterIP IP validation
This commit is contained in:
parent
c9cbe41347
commit
21ccf1d7fb
@ -21,7 +21,6 @@ import (
|
|||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"net"
|
"net"
|
||||||
"regexp"
|
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
@ -44,7 +43,6 @@ import (
|
|||||||
clientset "k8s.io/client-go/kubernetes"
|
clientset "k8s.io/client-go/kubernetes"
|
||||||
"k8s.io/client-go/tools/cache"
|
"k8s.io/client-go/tools/cache"
|
||||||
"k8s.io/kubernetes/test/e2e/framework"
|
"k8s.io/kubernetes/test/e2e/framework"
|
||||||
e2enetwork "k8s.io/kubernetes/test/e2e/framework/network"
|
|
||||||
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
e2enode "k8s.io/kubernetes/test/e2e/framework/node"
|
||||||
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
e2epod "k8s.io/kubernetes/test/e2e/framework/pod"
|
||||||
e2erc "k8s.io/kubernetes/test/e2e/framework/rc"
|
e2erc "k8s.io/kubernetes/test/e2e/framework/rc"
|
||||||
@ -819,15 +817,11 @@ func testReachabilityOverServiceName(serviceName string, sp v1.ServicePort, exec
|
|||||||
|
|
||||||
func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod *v1.Pod) error {
|
func testReachabilityOverClusterIP(clusterIP string, sp v1.ServicePort, execPod *v1.Pod) error {
|
||||||
// If .spec.clusterIP is set to "" or "None" for service, ClusterIP is not created, so reachability can not be tested over clusterIP:servicePort
|
// If .spec.clusterIP is set to "" or "None" for service, ClusterIP is not created, so reachability can not be tested over clusterIP:servicePort
|
||||||
isClusterIPV46, err := regexp.MatchString(e2enetwork.RegexIPv4+"||"+e2enetwork.RegexIPv6, clusterIP)
|
if net.ParseIP(clusterIP) == nil {
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("unable to parse ClusterIP: %s", clusterIP)
|
return fmt.Errorf("unable to parse ClusterIP: %s", clusterIP)
|
||||||
}
|
}
|
||||||
if isClusterIPV46 {
|
|
||||||
return testEndpointReachability(clusterIP, sp.Port, sp.Protocol, execPod)
|
return testEndpointReachability(clusterIP, sp.Port, sp.Protocol, execPod)
|
||||||
}
|
}
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
func testReachabilityOverExternalIP(externalIP string, sp v1.ServicePort, execPod *v1.Pod) error {
|
func testReachabilityOverExternalIP(externalIP string, sp v1.ServicePort, execPod *v1.Pod) error {
|
||||||
return testEndpointReachability(externalIP, sp.Port, sp.Protocol, execPod)
|
return testEndpointReachability(externalIP, sp.Port, sp.Protocol, execPod)
|
||||||
|
Loading…
Reference in New Issue
Block a user