@@ -50,6 +50,7 @@ import (
50
50
utilpointer "k8s.io/utils/pointer"
51
51
52
52
"github.com/onsi/ginkgo/v2"
53
+ "github.com/onsi/gomega"
53
54
54
55
imageutils "k8s.io/kubernetes/test/utils/image"
55
56
)
@@ -506,7 +507,7 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
506
507
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
507
508
func (rc * ResourceConsumer ) EnsureDesiredReplicasInRange (ctx context.Context , minDesiredReplicas , maxDesiredReplicas int , duration time.Duration , hpaName string ) {
508
509
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 ) {
510
511
replicas := rc .GetReplicas (ctx )
511
512
framework .Logf ("expecting there to be in [%d, %d] replicas (are: %d)" , minDesiredReplicas , maxDesiredReplicas , replicas )
512
513
as , err := rc .GetHpa (ctx , hpaName )
@@ -520,15 +521,9 @@ func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, mi
520
521
} else if replicas > maxDesiredReplicas {
521
522
return false , fmt .Errorf ("number of replicas above target" )
522
523
} 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.
524
525
}
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 ())
532
527
}
533
528
534
529
// Pause stops background goroutines responsible for consuming resources.
0 commit comments