From 1ffe3e87a2f1bd9edf24de402018d282e4a2c2b5 Mon Sep 17 00:00:00 2001 From: fabriziopandini Date: Fri, 8 Mar 2024 12:40:34 +0100 Subject: [PATCH] DumpResourcesForCluster should fail fast for i/o errors --- test/framework/alltypes_helpers.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/framework/alltypes_helpers.go b/test/framework/alltypes_helpers.go index ed19ac6d6b37..d499d4477c5d 100644 --- a/test/framework/alltypes_helpers.go +++ b/test/framework/alltypes_helpers.go @@ -156,6 +156,8 @@ func DumpResourcesForCluster(ctx context.Context, input DumpResourcesForClusterI for _, resource := range input.Resources { resourceList := new(unstructured.UnstructuredList) resourceList.SetGroupVersionKind(resource.GVK) + + var i int var listErr error _ = wait.PollUntilContextTimeout(ctx, retryableOperationInterval, retryableOperationTimeout, true, func(ctx context.Context) (bool, error) { if listErr = input.Lister.List(ctx, resourceList, client.InNamespace(resource.Namespace)); listErr != nil { @@ -165,6 +167,18 @@ func DumpResourcesForCluster(ctx context.Context, input DumpResourcesForClusterI if strings.HasSuffix(listErr.Error(), "connect: no route to host") { return true, nil } + // e.g This error happens when the API server for the workload cluster is down or the control plane endpoint + // can't be reached from the machine where the E2E test runs. + // NOTE: we consider this error won't recover after it happens at least 3 times in a row + if strings.HasSuffix(listErr.Error(), "i/o timeout") { + i++ + if i >= 3 { + return true, nil + } + return false, nil + } + + i = 0 return false, nil } return true, nil