mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 03:33:56 +00:00
Retry resource quota lookup until count stabilizes
On contended servers the service account controller can slow down, leading to the count changing during a run. Wait up to 5s for the count to stabilize, assuming that updates come at a consistent rate, and are not held indefinitely.
This commit is contained in:
parent
dd22743b54
commit
8a303b9908
@ -93,16 +93,27 @@ var _ = framework.KubeDescribe("ResourceQuota", func() {
|
|||||||
|
|
||||||
It("should create a ResourceQuota and capture the life of a secret.", func() {
|
It("should create a ResourceQuota and capture the life of a secret.", func() {
|
||||||
By("Discovering how many secrets are in namespace by default")
|
By("Discovering how many secrets are in namespace by default")
|
||||||
secrets, err := f.ClientSet.Core().Secrets(f.Namespace.Name).List(metav1.ListOptions{})
|
found, unchanged := 0, 0
|
||||||
Expect(err).NotTo(HaveOccurred())
|
wait.Poll(1*time.Second, 30*time.Second, func() (bool, error) {
|
||||||
defaultSecrets := fmt.Sprintf("%d", len(secrets.Items))
|
secrets, err := f.ClientSet.Core().Secrets(f.Namespace.Name).List(metav1.ListOptions{})
|
||||||
hardSecrets := fmt.Sprintf("%d", len(secrets.Items)+1)
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
if len(secrets.Items) == found {
|
||||||
|
// loop until the number of secrets has stabilized for 5 seconds
|
||||||
|
unchanged++
|
||||||
|
return unchanged > 4, nil
|
||||||
|
}
|
||||||
|
unchanged = 0
|
||||||
|
found = len(secrets.Items)
|
||||||
|
return false, nil
|
||||||
|
})
|
||||||
|
defaultSecrets := fmt.Sprintf("%d", found)
|
||||||
|
hardSecrets := fmt.Sprintf("%d", found+1)
|
||||||
|
|
||||||
By("Creating a ResourceQuota")
|
By("Creating a ResourceQuota")
|
||||||
quotaName := "test-quota"
|
quotaName := "test-quota"
|
||||||
resourceQuota := newTestResourceQuota(quotaName)
|
resourceQuota := newTestResourceQuota(quotaName)
|
||||||
resourceQuota.Spec.Hard[v1.ResourceSecrets] = resource.MustParse(hardSecrets)
|
resourceQuota.Spec.Hard[v1.ResourceSecrets] = resource.MustParse(hardSecrets)
|
||||||
resourceQuota, err = createResourceQuota(f.ClientSet, f.Namespace.Name, resourceQuota)
|
resourceQuota, err := createResourceQuota(f.ClientSet, f.Namespace.Name, resourceQuota)
|
||||||
Expect(err).NotTo(HaveOccurred())
|
Expect(err).NotTo(HaveOccurred())
|
||||||
|
|
||||||
By("Ensuring resource quota status is calculated")
|
By("Ensuring resource quota status is calculated")
|
||||||
|
Loading…
Reference in New Issue
Block a user