E2E ResourceQuota: fix pod creation flake

As can be seen in the output of a test failure in the CI, the test waits for
"quota-not-terminating" to be updated, but then fails because creating the pod
exceeds the "quota-terminating" quota which has not been updated yet. As both
ResourceQuotas apply, it needs to wait for both of them to be updated.

    STEP: Deleting the pod - k8s.io/kubernetes/test/e2e/apimachinery/resource_quota.go:1597 @ 05/18/25 07:50:46.531
    STEP: Ensuring resource quota status released the pod usage - k8s.io/kubernetes/test/e2e/apimachinery/resource_quota.go:1601 @ 05/18/25 07:50:46.547
    I0518 07:50:46.551520 75078 resource_quota.go:2508] Got expected ResourceQuota:
    ...
              name: quota-not-terminating
              namespace: scope-selectors-1836
              resourceVersion: "15914"
              uid: db72668e-2fe0-4543-ada2-a3ff0ac77dd5
            spec:
              hard:
                limits.cpu: "2"
                limits.memory: 1Gi
                pods: "1"
                requests.cpu: "1"
                requests.memory: 500Mi
              scopeSelector:
                matchExpressions:
                - operator: Exists
                  scopeName: NotTerminating
            status:
              hard:
                limits.cpu: "2"
                limits.memory: 1Gi
                pods: "1"
                requests.cpu: "1"
                requests.memory: 500Mi
              used:
                limits.cpu: "0"
                limits.memory: "0"
                pods: "0"
                requests.cpu: "0"
                requests.memory: "0"
    STEP: Creating a terminating pod - k8s.io/kubernetes/test/e2e/apimachinery/resource_quota.go:1610 @ 05/18/25 07:50:46.551
    I0518 07:50:46.560944 75078 resource_quota.go:1612] Unexpected error:
        <*errors.StatusError | 0xc002dba500>:
        pods "terminating-pod" is forbidden: exceeded quota: quota-terminating, requested: pods=1, used: pods=1, limited: pods=1
        {
            ErrStatus:
                code: 403
                details:
                  kind: pods
                  name: terminating-pod
                message: 'pods "terminating-pod" is forbidden: exceeded quota: quota-terminating,
                  requested: pods=1, used: pods=1, limited: pods=1'
                metadata: {}
                reason: Forbidden
                status: Failure,
        }
    [FAILED] pods "terminating-pod" is forbidden: exceeded quota: quota-terminating, requested: pods=1, used: pods=1, limited: pods=1
This commit is contained in:
Patrick Ohly
2025-05-19 09:27:35 +02:00
parent 4b10ba9eef
commit 4a353d07e4

View File

@@ -1606,6 +1606,8 @@ var _ = SIGDescribe("ResourceQuota", func() {
usedResources[v1.ResourceLimitsMemory] = resource.MustParse("0")
err = waitForResourceQuota(ctx, f.ClientSet, f.Namespace.Name, resourceQuotaNotTerminating.Name, usedResources)
framework.ExpectNoError(err)
err = waitForResourceQuota(ctx, f.ClientSet, f.Namespace.Name, resourceQuotaTerminating.Name, usedResources)
framework.ExpectNoError(err)
ginkgo.By("Creating a terminating pod")
_, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, pod2, metav1.CreateOptions{})