Skip to content

Commit

Permalink
Merge pull request #10238 from fabriziopandini/improve-fail-fast-for-…
Browse files Browse the repository at this point in the history
…DumpResourcesForCluster

🌱 DumpResourcesForCluster should fail fast for i/o errors
  • Loading branch information
k8s-ci-robot committed Mar 11, 2024
2 parents fed27ee + 1ffe3e8 commit 2802384
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/framework/alltypes_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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
Expand Down

0 comments on commit 2802384

Please sign in to comment.