@@ -225,7 +225,7 @@ func (e *quotaEvaluator) checkAttributes(ns string, admissionAttributes []*admis
225225//     updates failed on conflict errors and we have retries left, re-get the failed quota from our cache for the latest version 
226226//     and recurse into this method with the subset.  It's safe for us to evaluate ONLY the subset, because the other quota 
227227//     documents for these waiters have already been evaluated.  Step 1, will mark all the ones that should already have succeeded. 
228- func  (e  * quotaEvaluator ) checkQuotas (quotas  []corev1.ResourceQuota , admissionAttributes  []* admissionWaiter , remainingRetries  int ) {
228+ func  (e  * quotaEvaluator ) checkQuotas (quotas  []corev1.ResourceQuota , admissionAttributes  []* admissionWaiter , retries  int ) {
229229	// yet another copy to compare against originals to see if we actually have deltas 
230230	originalQuotas , err  :=  copyQuotas (quotas )
231231	if  err  !=  nil  {
@@ -277,6 +277,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []corev1.ResourceQuota, admissionAtt
277277	// 3. if the quota changed and the update fails, add the original to a retry list 
278278	var  updatedFailedQuotas  []corev1.ResourceQuota 
279279	var  lastErr  error 
280+ 	remainingRetries  :=  retries  -  1 
280281	for  i  :=  range  quotas  {
281282		newQuota  :=  quotas [i ]
282283
@@ -286,6 +287,10 @@ func (e *quotaEvaluator) checkQuotas(quotas []corev1.ResourceQuota, admissionAtt
286287		}
287288
288289		if  err  :=  e .quotaAccessor .UpdateQuotaStatus (& newQuota ); err  !=  nil  {
290+ 			// If there is a transient update error, it doesn't count against the retry quota 
291+ 			if  isRetryableError (err ) {
292+ 				remainingRetries  =  retries 
293+ 			}
289294			updatedFailedQuotas  =  append (updatedFailedQuotas , newQuota )
290295			lastErr  =  err 
291296		}
@@ -338,7 +343,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []corev1.ResourceQuota, admissionAtt
338343			}
339344		}
340345	}
341- 	e .checkQuotas (quotasToCheck , admissionAttributes , remainingRetries - 1 )
346+ 	e .checkQuotas (quotasToCheck , admissionAttributes , remainingRetries )
342347}
343348
344349func  copyQuotas (in  []corev1.ResourceQuota ) ([]corev1.ResourceQuota , error ) {
@@ -723,3 +728,13 @@ func hasUsageStats(resourceQuota *corev1.ResourceQuota, interestingResources []c
723728	}
724729	return  true 
725730}
731+ 
732+ func  isRetryableError (err  error ) bool  {
733+ 	switch  {
734+ 	case  apierrors .IsConflict (err ):
735+ 		return  true 
736+ 	default :
737+ 		return  false 
738+ 
739+ 	}
740+ }
0 commit comments