mirror of https://github.com/k3s-io/k3s
[Federation][init-06] Check for the availability of federation API server's service loadbalancer address before waiting.
This speeds up the tests. Otherwise tests end up unnecessarily waiting for the poll interval/duration which is 5 seconds right now.pull/6/head
parent
b0022fcd7b
commit
caef02cf43
|
@ -242,7 +242,7 @@ func waitForLoadBalancerAddress(clientset *client.Clientset, svc *api.Service) (
|
||||||
ips := []string{}
|
ips := []string{}
|
||||||
hostnames := []string{}
|
hostnames := []string{}
|
||||||
|
|
||||||
err := wait.PollInfinite(lbAddrRetryInterval, func() (bool, error) {
|
err := wait.PollImmediateInfinite(lbAddrRetryInterval, func() (bool, error) {
|
||||||
pollSvc, err := clientset.Core().Services(svc.Namespace).Get(svc.Name)
|
pollSvc, err := clientset.Core().Services(svc.Namespace).Get(svc.Name)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false, nil
|
return false, nil
|
||||||
|
|
|
@ -192,6 +192,20 @@ func PollInfinite(interval time.Duration, condition ConditionFunc) error {
|
||||||
return PollUntil(interval, condition, done)
|
return PollUntil(interval, condition, done)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// PollImmediateInfinite is identical to PollInfinite, except that it
|
||||||
|
// performs the first check immediately, not waiting interval
|
||||||
|
// beforehand.
|
||||||
|
func PollImmediateInfinite(interval time.Duration, condition ConditionFunc) error {
|
||||||
|
done, err := condition()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
if done {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
return PollInfinite(interval, condition)
|
||||||
|
}
|
||||||
|
|
||||||
// PollUntil is like Poll, but it takes a stop change instead of total duration
|
// PollUntil is like Poll, but it takes a stop change instead of total duration
|
||||||
func PollUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error {
|
func PollUntil(interval time.Duration, condition ConditionFunc, stopCh <-chan struct{}) error {
|
||||||
return WaitFor(poller(interval, 0), condition, stopCh)
|
return WaitFor(poller(interval, 0), condition, stopCh)
|
||||||
|
|
Loading…
Reference in New Issue