Skip to content

Commit 2802384

Browse files
authored
Merge pull request kubernetes-sigs#10238 from fabriziopandini/improve-fail-fast-for-DumpResourcesForCluster
🌱 DumpResourcesForCluster should fail fast for i/o errors
2 parents fed27ee + 1ffe3e8 commit 2802384

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

test/framework/alltypes_helpers.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,8 @@ func DumpResourcesForCluster(ctx context.Context, input DumpResourcesForClusterI
156156
for _, resource := range input.Resources {
157157
resourceList := new(unstructured.UnstructuredList)
158158
resourceList.SetGroupVersionKind(resource.GVK)
159+
160+
var i int
159161
var listErr error
160162
_ = wait.PollUntilContextTimeout(ctx, retryableOperationInterval, retryableOperationTimeout, true, func(ctx context.Context) (bool, error) {
161163
if listErr = input.Lister.List(ctx, resourceList, client.InNamespace(resource.Namespace)); listErr != nil {
@@ -165,6 +167,18 @@ func DumpResourcesForCluster(ctx context.Context, input DumpResourcesForClusterI
165167
if strings.HasSuffix(listErr.Error(), "connect: no route to host") {
166168
return true, nil
167169
}
170+
// e.g This error happens when the API server for the workload cluster is down or the control plane endpoint
171+
// can't be reached from the machine where the E2E test runs.
172+
// NOTE: we consider this error won't recover after it happens at least 3 times in a row
173+
if strings.HasSuffix(listErr.Error(), "i/o timeout") {
174+
i++
175+
if i >= 3 {
176+
return true, nil
177+
}
178+
return false, nil
179+
}
180+
181+
i = 0
168182
return false, nil
169183
}
170184
return true, nil

0 commit comments

Comments
 (0)