From 260a720a8514725de7b56aee150ea1c55928922c Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Tue, 10 Jun 2025 09:10:41 -0400 Subject: [PATCH] Rate-limit the LoadBalancer rolling update test It was trying to reconnect to the LoadBalancer as fast as possible to try to catch any transient problems, but "as fast as possible" ended up meaning about 12,500 times a second, which is clearly excessive. Limit it to 100 times a second. --- test/e2e/network/loadbalancer.go | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/test/e2e/network/loadbalancer.go b/test/e2e/network/loadbalancer.go index b91d9f3b754..9e8b9124c9d 100644 --- a/test/e2e/network/loadbalancer.go +++ b/test/e2e/network/loadbalancer.go @@ -1331,12 +1331,13 @@ func testRollingUpdateLBConnectivityDisruption(ctx context.Context, f *framework var totalRequests uint64 = 0 var networkErrors uint64 = 0 var httpErrors uint64 = 0 - done := make(chan struct{}) - defer close(done) + + pollCtx, cancel := context.WithCancel(ctx) + defer cancel() go func() { defer ginkgo.GinkgoRecover() - wait.Until(func() { + _ = wait.PollUntilContextCancel(pollCtx, time.Second/100, true, func(ctx context.Context) (bool, error) { atomic.AddUint64(&totalRequests, 1) client := &http.Client{ Transport: utilnet.SetTransportDefaults(&http.Transport{ @@ -1351,26 +1352,27 @@ func testRollingUpdateLBConnectivityDisruption(ctx context.Context, f *framework if err != nil { framework.Logf("Got error testing for reachability of %s: %v", url, err) atomic.AddUint64(&networkErrors, 1) - return + return false, nil } defer func() { _ = resp.Body.Close() }() if resp.StatusCode != http.StatusOK { framework.Logf("Got bad status code: %d", resp.StatusCode) atomic.AddUint64(&httpErrors, 1) - return + return false, nil } body, err := io.ReadAll(resp.Body) if err != nil { framework.Logf("Got error reading HTTP body: %v", err) atomic.AddUint64(&httpErrors, 1) - return + return false, nil } if string(body) != msg { framework.Logf("The response body does not contain expected string %s", string(body)) atomic.AddUint64(&httpErrors, 1) - return + return false, nil } - }, time.Duration(0), done) + return false, nil + }) }() ginkgo.By("Triggering DaemonSet rolling update several times")