mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-23 03:41:45 +00:00
Add service reachability polling to avoid flakiness
This commit is contained in:
parent
125fb72850
commit
eddd7da462
@ -78,4 +78,7 @@ const (
|
||||
|
||||
// ServiceEndpointsTimeout is the maximum time in which endpoints for the service should be created.
|
||||
ServiceEndpointsTimeout = 2 * time.Minute
|
||||
|
||||
// ServiceReachabilityShortPollTimeout is the maximum time in which service must be reachable during polling.
|
||||
ServiceReachabilityShortPollTimeout = 2 * time.Minute
|
||||
)
|
||||
|
@ -812,8 +812,14 @@ func testEndpointReachability(endpoint string, port int32, protocol v1.Protocol,
|
||||
e2elog.Failf("Service reachablity check is not supported for %v", protocol)
|
||||
}
|
||||
if cmd != "" {
|
||||
_, err := framework.RunHostCmd(execPod.Namespace, execPod.Name, cmd)
|
||||
framework.ExpectNoError(err, "Service is not reachable on following endpoint %s over %s protocol", ep, protocol)
|
||||
err := wait.PollImmediate(1*time.Second, ServiceReachabilityShortPollTimeout, func() (bool, error) {
|
||||
if _, err := framework.RunHostCmd(execPod.Namespace, execPod.Name, cmd); err != nil {
|
||||
e2elog.Logf("Service reachability failing with error: %v\nRetrying...", err)
|
||||
return false, nil
|
||||
}
|
||||
return true, nil
|
||||
})
|
||||
framework.ExpectNoError(err, "Service is not reachable within %v timeout on endpoint %s over %s protocol", ServiceReachabilityShortPollTimeout, ep, protocol)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user