Merge pull request #112663 from aojea/reachability

do not assume backend on e2e service jig
This commit is contained in:
Kubernetes Prow Robot 2022-09-22 12:51:28 -07:00 committed by GitHub
commit 4af079a3a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -902,24 +902,20 @@ func testEndpointReachability(endpoint string, port int32, protocol v1.Protocol,
cmd := ""
switch protocol {
case v1.ProtocolTCP:
cmd = fmt.Sprintf("echo hostName | nc -v -t -w 2 %s %v", endpoint, port)
cmd = fmt.Sprintf("nc -v -z -w 2 %s %v", endpoint, port)
case v1.ProtocolUDP:
cmd = fmt.Sprintf("echo hostName | nc -v -u -w 2 %s %v", endpoint, port)
cmd = fmt.Sprintf("nc -v -z -u -w 2 %s %v", endpoint, port)
default:
return fmt.Errorf("service reachability check is not supported for %v", protocol)
}
err := wait.PollImmediate(1*time.Second, ServiceReachabilityShortPollTimeout, func() (bool, error) {
stdout, err := framework.RunHostCmd(execPod.Namespace, execPod.Name, cmd)
_, err := framework.RunHostCmd(execPod.Namespace, execPod.Name, cmd)
if err != nil {
framework.Logf("Service reachability failing with error: %v\nRetrying...", err)
return false, nil
}
trimmed := strings.TrimSpace(stdout)
if trimmed != "" {
return true, nil
}
return false, nil
return true, nil
})
if err != nil {
return fmt.Errorf("service is not reachable within %v timeout on endpoint %s over %s protocol", ServiceReachabilityShortPollTimeout, ep, protocol)