@@ -210,10 +210,9 @@ var _ = Describe("TenantQuota Controller", func() {
210210 f := & agentraxv1alpha1.TenantQuota {}
211211 g .Expect (k8sClient .Get (ctx , namespacedName ("tq-clearoq" , tqNS ), f )).To (Succeed ())
212212 cond := apimeta .FindStatusCondition (f .Status .Conditions , agentraxv1alpha1 .ConditionOverQuota )
213- // Condition should be absent or False once usage normalises.
214- if cond != nil {
215- g .Expect (cond .Status ).To (Equal (metav1 .ConditionFalse ))
216- }
213+ // The reconciler calls RemoveStatusCondition, so the condition
214+ // must be fully absent once usage normalises.
215+ g .Expect (cond ).To (BeNil ())
217216 }, timeout , interval ).Should (Succeed ())
218217 })
219218
@@ -264,6 +263,17 @@ var _ = Describe("TenantQuota Controller", func() {
264263 ad1 := makeBasicAD ("ad-reject-1" , tqNS , "tq-reject" , 2 )
265264 Expect (k8sClient .Create (ctx , ad1 )).To (Succeed ())
266265
266+ // Wait for the reconciler to commit ad1's usage into TQ status before
267+ // testing ad2. Without this, ad2 may be tried while the in-flight
268+ // reservation is still live and the quota arithmetic has not yet been
269+ // persisted, causing the rejection to rely solely on the reservation
270+ // TTL which may have already expired.
271+ Eventually (func (g Gomega ) {
272+ f := & agentraxv1alpha1.TenantQuota {}
273+ g .Expect (k8sClient .Get (ctx , namespacedName ("tq-reject" , tqNS ), f )).To (Succeed ())
274+ g .Expect (f .Status .UsedAgents ).To (BeNumerically ("==" , 1 ))
275+ }, timeout , interval ).Should (Succeed ())
276+
267277 // Second AD would push usedAgents to 2 > maxAgents=1 → rejected.
268278 ad2 := makeBasicAD ("ad-reject-2" , tqNS , "tq-reject" , 2 )
269279 err := k8sClient .Create (ctx , ad2 )
0 commit comments