From a7ff868daea9ccb9d719ea0d3a84083efdc18213 Mon Sep 17 00:00:00 2001 From: Niels de Vos Date: Tue, 20 Jul 2021 16:23:14 +0200 Subject: [PATCH] e2e: retry getting the Services for Ceph MON on failures In case listing the Kubernetes Services fails, the following error is returned immediately: failed to create configmap with error failed to list services: etcdserver: request timed out Wrapping the listing of the Services in a PollImmediate() routine, adds a retry in case of common temporary issues. Signed-off-by: Niels de Vos --- e2e/utils.go | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/e2e/utils.go b/e2e/utils.go index 13246077d..3769a871d 100644 --- a/e2e/utils.go +++ b/e2e/utils.go @@ -71,9 +71,23 @@ func getMons(ns string, c kubernetes.Interface) ([]string, error) { } services := make([]string, 0) - svcList, err := c.CoreV1().Services(ns).List(context.TODO(), opt) + var svcList *v1.ServiceList + t := time.Duration(deployTimeout) * time.Minute + err := wait.PollImmediate(poll, t, func() (bool, error) { + var svcErr error + svcList, svcErr = c.CoreV1().Services(ns).List(context.TODO(), opt) + if svcErr != nil { + if isRetryableAPIError(svcErr) { + return false, nil + } + + return false, fmt.Errorf("failed to list Services in namespace %q: %w", ns, svcErr) + } + + return true, nil + }) if err != nil { - return services, fmt.Errorf("failed to list services: %w", err) + return services, fmt.Errorf("could not get Services: %w", err) } for i := range svcList.Items { s := fmt.Sprintf(