Skip to content

Commit 4b1b9a1

Browse files
committed
Fix issue with client rate limiter when polling
Signed-off-by: James Sturtevant <[email protected]>
1 parent 7dea016 commit 4b1b9a1

File tree

1 file changed

+4
-9
lines changed

1 file changed

+4
-9
lines changed

test/e2e/framework/autoscaling/autoscaling_utils.go

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ import (
5050
utilpointer "k8s.io/utils/pointer"
5151

5252
"github.com/onsi/ginkgo/v2"
53+
"github.com/onsi/gomega"
5354

5455
imageutils "k8s.io/kubernetes/test/utils/image"
5556
)
@@ -506,7 +507,7 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
506507
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
507508
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
508509
interval := 10 * time.Second
509-
err := wait.PollUntilContextTimeout(ctx, interval, duration, true, func(ctx context.Context) (bool, error) {
510+
gomega.Consistently(ctx, framework.HandleRetry(func(ctx context.Context) (bool, error) {
510511
replicas := rc.GetReplicas(ctx)
511512
framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas)
512513
as, err := rc.GetHpa(ctx, hpaName)
@@ -520,15 +521,9 @@ func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, mi
520521
} else if replicas > maxDesiredReplicas {
521522
return false, fmt.Errorf("number of replicas above target")
522523
} else {
523-
return false, nil // Expected number of replicas found. Continue polling until timeout.
524+
return true, nil // Expected number of replicas found. Continue polling until timeout.
524525
}
525-
})
526-
// The call above always returns an error, but if it is timeout, it's OK (condition satisfied all the time).
527-
if wait.Interrupted(err) {
528-
framework.Logf("Number of replicas was stable over %v", duration)
529-
return
530-
}
531-
framework.ExpectNoErrorWithOffset(1, err)
526+
})).WithTimeout(duration).WithPolling(interval).Should(gomega.BeTrue())
532527
}
533528

534529
// Pause stops background goroutines responsible for consuming resources.

0 commit comments

Comments
 (0)