mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 13:55:41 +00:00
Fix issue with client rate limiter when polling
Signed-off-by: James Sturtevant <jstur@microsoft.com>
This commit is contained in:
parent
7dea016c1f
commit
4b1b9a198a
@ -50,6 +50,7 @@ import (
|
|||||||
utilpointer "k8s.io/utils/pointer"
|
utilpointer "k8s.io/utils/pointer"
|
||||||
|
|
||||||
"github.com/onsi/ginkgo/v2"
|
"github.com/onsi/ginkgo/v2"
|
||||||
|
"github.com/onsi/gomega"
|
||||||
|
|
||||||
imageutils "k8s.io/kubernetes/test/utils/image"
|
imageutils "k8s.io/kubernetes/test/utils/image"
|
||||||
)
|
)
|
||||||
@ -506,7 +507,7 @@ func (rc *ResourceConsumer) WaitForReplicas(ctx context.Context, desiredReplicas
|
|||||||
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
|
// EnsureDesiredReplicasInRange ensure the replicas is in a desired range
|
||||||
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
|
func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, minDesiredReplicas, maxDesiredReplicas int, duration time.Duration, hpaName string) {
|
||||||
interval := 10 * time.Second
|
interval := 10 * time.Second
|
||||||
err := wait.PollUntilContextTimeout(ctx, interval, duration, true, func(ctx context.Context) (bool, error) {
|
gomega.Consistently(ctx, framework.HandleRetry(func(ctx context.Context) (bool, error) {
|
||||||
replicas := rc.GetReplicas(ctx)
|
replicas := rc.GetReplicas(ctx)
|
||||||
framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas)
|
framework.Logf("expecting there to be in [%d, %d] replicas (are: %d)", minDesiredReplicas, maxDesiredReplicas, replicas)
|
||||||
as, err := rc.GetHpa(ctx, hpaName)
|
as, err := rc.GetHpa(ctx, hpaName)
|
||||||
@ -520,15 +521,9 @@ func (rc *ResourceConsumer) EnsureDesiredReplicasInRange(ctx context.Context, mi
|
|||||||
} else if replicas > maxDesiredReplicas {
|
} else if replicas > maxDesiredReplicas {
|
||||||
return false, fmt.Errorf("number of replicas above target")
|
return false, fmt.Errorf("number of replicas above target")
|
||||||
} else {
|
} else {
|
||||||
return false, nil // Expected number of replicas found. Continue polling until timeout.
|
return true, nil // Expected number of replicas found. Continue polling until timeout.
|
||||||
}
|
}
|
||||||
})
|
})).WithTimeout(duration).WithPolling(interval).Should(gomega.BeTrue())
|
||||||
// The call above always returns an error, but if it is timeout, it's OK (condition satisfied all the time).
|
|
||||||
if wait.Interrupted(err) {
|
|
||||||
framework.Logf("Number of replicas was stable over %v", duration)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
framework.ExpectNoErrorWithOffset(1, err)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pause stops background goroutines responsible for consuming resources.
|
// Pause stops background goroutines responsible for consuming resources.
|
||||||
|
Loading…
Reference in New Issue
Block a user