From 20863a8b4390d275925338571e7a46105177a6cf Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Fri, 11 Sep 2020 12:44:16 -0700 Subject: [PATCH] add retry for creating metrics grabber to fix test flakes --- .../instrumentation/monitoring/metrics_grabber.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/e2e/instrumentation/monitoring/metrics_grabber.go b/test/e2e/instrumentation/monitoring/metrics_grabber.go index 6aab917bad7..eccb085796d 100644 --- a/test/e2e/instrumentation/monitoring/metrics_grabber.go +++ b/test/e2e/instrumentation/monitoring/metrics_grabber.go @@ -18,7 +18,9 @@ package monitoring import ( "context" + "fmt" "strings" + "time" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" clientset "k8s.io/client-go/kubernetes" @@ -40,8 +42,16 @@ var _ = instrumentation.SIGDescribe("MetricsGrabber", func() { c = f.ClientSet ec = f.KubemarkExternalClusterClientSet framework.ExpectNoError(err) - grabber, err = e2emetrics.NewMetricsGrabber(c, ec, true, true, true, true, true) - framework.ExpectNoError(err) + gomega.Eventually(func() error { + grabber, err = e2emetrics.NewMetricsGrabber(c, ec, true, true, true, true, true) + if err != nil { + return fmt.Errorf("failed to create metrics grabber: %v", err) + } + if !grabber.HasControlPlanePods() { + return fmt.Errorf("unable to get find control plane pods") + } + return nil + }, 5*time.Minute, 10*time.Second).Should(gomega.BeNil()) }) ginkgo.It("should grab all metrics from API server.", func() {