From 4a353d07e4fbfa5d674257c93b6dbc70e18a5d2f Mon Sep 17 00:00:00 2001 From: Patrick Ohly Date: Mon, 19 May 2025 09:27:35 +0200 Subject: [PATCH] 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 --- test/e2e/apimachinery/resource_quota.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/e2e/apimachinery/resource_quota.go b/test/e2e/apimachinery/resource_quota.go index bf8bc8d241d..04d569002f2 100644 --- a/test/e2e/apimachinery/resource_quota.go +++ b/test/e2e/apimachinery/resource_quota.go @@ -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{})