Skip to content

Commit d203bb5

Browse files
committed
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
1 parent 1f07da7 commit d203bb5

File tree

1 file changed

+23
-8
lines changed

1 file changed

+23
-8
lines changed

test/e2e/apimachinery/resource_quota.go

Lines changed: 23 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,21 +1186,36 @@ var _ = SIGDescribe("ResourceQuota", func() {
11861186
})
11871187
framework.ExpectNoError(err, "failed to locate ResourceQuota %q in namespace %q", patchedResourceQuota.Name, ns)
11881188

1189-
err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 5*time.Minute, true, func(ctx context.Context) (bool, error) {
1189+
// the resource_quota_controller ignores changes to the status so we have to wait for a full resync of the controller
1190+
// to reconcile the status again, this full resync is set every 5 minutes by default so we need to poll at least one
1191+
// minute more just in case we we start to poll just after the full resync has happened and he have to wait until
1192+
// next full resync.
1193+
// Ref: https://issues.k8s.io/121911
1194+
err = wait.PollUntilContextTimeout(ctx, 5*time.Second, 6*time.Minute, true, func(ctx context.Context) (bool, error) {
11901195
resourceQuotaResult, err := rqClient.Get(ctx, rqName, metav1.GetOptions{})
1191-
framework.ExpectNoError(err)
1196+
if err != nil {
1197+
return false, nil
1198+
}
11921199

1193-
if apiequality.Semantic.DeepEqual(resourceQuotaResult.Spec.Hard.Cpu(), resourceQuotaResult.Status.Hard.Cpu()) {
1194-
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())
1195-
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())
1200+
if *resourceQuotaResult.Spec.Hard.Cpu() == *resourceQuotaResult.Status.Hard.Cpu() {
1201+
if *resourceQuotaResult.Status.Hard.Cpu() != resource.MustParse("1") {
1202+
framework.Logf("Hard cpu status value for ResourceQuota %q is %s not 1.", repatchedResourceQuota.Name, resourceQuotaResult.Status.Hard.Cpu().String())
1203+
return false, nil
1204+
}
1205+
if *resourceQuotaResult.Status.Hard.Memory() != resource.MustParse("1Gi") {
1206+
framework.Logf("Hard memory status value for ResourceQuota %q is %s not 1Gi.", repatchedResourceQuota.Name, resourceQuotaResult.Status.Hard.Memory().String())
1207+
return false, nil
1208+
}
11961209
framework.Logf("ResourceQuota %q Spec was unchanged and /status reset", resourceQuotaResult.Name)
1197-
11981210
return true, nil
11991211
}
1200-
1212+
framework.Logf("ResourceQuota %q Spec and Status does not match: %#v", resourceQuotaResult.Name, resourceQuotaResult)
12011213
return false, nil
12021214
})
1203-
framework.ExpectNoError(err)
1215+
if err != nil {
1216+
framework.Failf("Error waiting for ResourceQuota %q to reset its Status: %v", patchedResourceQuota.Name, err)
1217+
}
1218+
12041219
})
12051220
})
12061221

0 commit comments

Comments
 (0)