From 3257020d454d3d9bb66c6fe71143897d9950520e Mon Sep 17 00:00:00 2001 From: Chris Henzie Date: Mon, 2 Feb 2026 10:38:54 -0800 Subject: [PATCH] Fix race condition in ResourceQuota e2e test This test occasionally fails when creating the "terminating pod" with a 403 Forbidden error. This is likely because kube-apiserver's internal cache is stale, even though the test has already verified the ResourceQuota status in etcd was correct via `Get()`. Addresses this issue by wrapping Pod creation in a polling loop that retries on forbidden errors. Signed-off-by: Chris Henzie --- test/e2e/apimachinery/resource_quota.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/test/e2e/apimachinery/resource_quota.go b/test/e2e/apimachinery/resource_quota.go index 2a6d865fd12..cfa62c63df7 100644 --- a/test/e2e/apimachinery/resource_quota.go +++ b/test/e2e/apimachinery/resource_quota.go @@ -1614,7 +1614,17 @@ var _ = SIGDescribe("ResourceQuota", func() { framework.ExpectNoError(err) ginkgo.By("Creating a terminating pod") - _, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, pod2, metav1.CreateOptions{}) + // Retry creating the pod as the admission controller's view of the quota usage may lag behind the ResourceQuota status. + err = wait.PollUntilContextTimeout(ctx, 1*time.Second, 30*time.Second, false, func(ctx context.Context) (bool, error) { + _, err = f.ClientSet.CoreV1().Pods(f.Namespace.Name).Create(ctx, pod2, metav1.CreateOptions{}) + if err != nil { + if apierrors.IsForbidden(err) { + return false, nil + } + return false, err + } + return true, nil + }) framework.ExpectNoError(err) ginkgo.By("Ensuring resource quota with terminating scope captures the pod usage")