do not wait for endpoints that shouldn't exist

If there are no replicas defined, do not wait
around for the respective endpoints, since none
are expected.
This commit is contained in:
Tim Reddehase 2019-02-03 16:53:38 +01:00
parent 018a1e4d94
commit 16dcace669

View file

@ -144,6 +144,9 @@ func WaitForPodsReady(kubeClientSet kubernetes.Interface, timeout time.Duration,
// WaitForEndpoints waits for a given amount of time until an endpoint contains. // WaitForEndpoints waits for a given amount of time until an endpoint contains.
func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, name, ns string, expectedEndpoints int) error { func WaitForEndpoints(kubeClientSet kubernetes.Interface, timeout time.Duration, name, ns string, expectedEndpoints int) error {
if expectedEndpoints == 0 {
return nil
}
return wait.Poll(2*time.Second, timeout, func() (bool, error) { return wait.Poll(2*time.Second, timeout, func() (bool, error) {
endpoint, err := kubeClientSet.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{}) endpoint, err := kubeClientSet.CoreV1().Endpoints(ns).Get(name, metav1.GetOptions{})
if k8sErrors.IsNotFound(err) { if k8sErrors.IsNotFound(err) {