From d203bb54f8a5937f6b30a0b9f22471632e9c42ad Mon Sep 17 00:00:00 2001 From: Antonio Ojea Date: Sat, 18 Nov 2023 18:54:02 +0000 Subject: [PATCH] fix flake on conformance e2e test ResourceQuota controller should apply changes to a resourcequota status The e2e test patch the status of a ResourceQuota resources and tries to verify the controller reset its status, however, the controller ignores the updates and only reconcile the objects every a predefined interval, by default 5 minutes. Since the test polls for 5 minutes, there are some edge cases that the time to reconcile the object by the reconcile loop is greater than 5 minutes failing the test. To take into account the time to reconcile the objects and the reconcile loop period, we increase by one minute the poll loop. Change-Id: I30f7fda36cdfb47c543b5b2b120e39f7d6c2442d --- test/e2e/apimachinery/resource_quota.go | 35 ++++++++++++++++++------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/test/e2e/apimachinery/resource_quota.go b/test/e2e/apimachinery/resource_quota.go index e9f1fcf0940..d02bb2ae706 100644 --- a/test/e2e/apimachinery/resource_quota.go +++ b/test/e2e/apimachinery/resource_quota.go @@ -1186,21 +1186,36 @@ var _ = SIGDescribe("ResourceQuota", func() { }) framework.ExpectNoError(err, "failed to locate ResourceQuota %q in namespace %q", patchedResourceQuota.Name, ns) - err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 5*time.Minute, true, func(ctx context.Context) (bool, error) { + // the resource_quota_controller ignores changes to the status so we have to wait for a full resync of the controller + // to reconcile the status again, this full resync is set every 5 minutes by default so we need to poll at least one + // minute more just in case we we start to poll just after the full resync has happened and he have to wait until + // next full resync. + // Ref: https://issues.k8s.io/121911 + err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 6*time.Minute, true, func(ctx context.Context) (bool, error) { resourceQuotaResult, err := rqClient.Get(ctx, rqName, metav1.GetOptions{}) - framework.ExpectNoError(err) - - if apiequality.Semantic.DeepEqual(resourceQuotaResult.Spec.Hard.Cpu(), resourceQuotaResult.Status.Hard.Cpu()) { - gomega.Expect(*resourceQuotaResult.Status.Hard.Cpu()).To(gomega.Equal(resource.MustParse("1")), "Hard cpu value for ResourceQuota %q is %s not 1.", repatchedResourceQuota.Name, repatchedResourceQuota.Status.Hard.Cpu().String()) - gomega.Expect(*resourceQuotaResult.Status.Hard.Memory()).To(gomega.Equal(resource.MustParse("1Gi")), "Hard memory value for ResourceQuota %q is %s not 1Gi.", repatchedResourceQuota.Name, repatchedResourceQuota.Status.Hard.Memory().String()) - framework.Logf("ResourceQuota %q Spec was unchanged and /status reset", resourceQuotaResult.Name) - - return true, nil + if err != nil { + return false, nil } + if *resourceQuotaResult.Spec.Hard.Cpu() == *resourceQuotaResult.Status.Hard.Cpu() { + if *resourceQuotaResult.Status.Hard.Cpu() != resource.MustParse("1") { + framework.Logf("Hard cpu status value for ResourceQuota %q is %s not 1.", repatchedResourceQuota.Name, resourceQuotaResult.Status.Hard.Cpu().String()) + return false, nil + } + if *resourceQuotaResult.Status.Hard.Memory() != resource.MustParse("1Gi") { + framework.Logf("Hard memory status value for ResourceQuota %q is %s not 1Gi.", repatchedResourceQuota.Name, resourceQuotaResult.Status.Hard.Memory().String()) + return false, nil + } + framework.Logf("ResourceQuota %q Spec was unchanged and /status reset", resourceQuotaResult.Name) + return true, nil + } + framework.Logf("ResourceQuota %q Spec and Status does not match: %#v", resourceQuotaResult.Name, resourceQuotaResult) return false, nil }) - framework.ExpectNoError(err) + if err != nil { + framework.Failf("Error waiting for ResourceQuota %q to reset its Status: %v", patchedResourceQuota.Name, err) + } + }) })