Skip to content

Commit

Permalink
fix flake on conformance e2e test ResourceQuota controller should app…
Browse files Browse the repository at this point in the history
…ly 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
  • Loading branch information
aojea committed Nov 18, 2023
1 parent 1f07da7 commit d203bb5
Showing 1 changed file with 23 additions and 8 deletions.
31 changes: 23 additions & 8 deletions test/e2e/apimachinery/resource_quota.go
Expand Up @@ -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 err != nil {
return false, nil
}

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())
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)
}

})
})

Expand Down

0 comments on commit d203bb5

Please sign in to comment.