@@ -225,7 +225,7 @@ func (e *quotaEvaluator) checkAttributes(ns string, admissionAttributes []*admis
225
225
// updates failed on conflict errors and we have retries left, re-get the failed quota from our cache for the latest version
226
226
// and recurse into this method with the subset. It's safe for us to evaluate ONLY the subset, because the other quota
227
227
// 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 ) {
229
229
// yet another copy to compare against originals to see if we actually have deltas
230
230
originalQuotas , err := copyQuotas (quotas )
231
231
if err != nil {
@@ -277,6 +277,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []corev1.ResourceQuota, admissionAtt
277
277
// 3. if the quota changed and the update fails, add the original to a retry list
278
278
var updatedFailedQuotas []corev1.ResourceQuota
279
279
var lastErr error
280
+ remainingRetries := retries - 1
280
281
for i := range quotas {
281
282
newQuota := quotas [i ]
282
283
@@ -286,6 +287,10 @@ func (e *quotaEvaluator) checkQuotas(quotas []corev1.ResourceQuota, admissionAtt
286
287
}
287
288
288
289
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
+ }
289
294
updatedFailedQuotas = append (updatedFailedQuotas , newQuota )
290
295
lastErr = err
291
296
}
@@ -338,7 +343,7 @@ func (e *quotaEvaluator) checkQuotas(quotas []corev1.ResourceQuota, admissionAtt
338
343
}
339
344
}
340
345
}
341
- e .checkQuotas (quotasToCheck , admissionAttributes , remainingRetries - 1 )
346
+ e .checkQuotas (quotasToCheck , admissionAttributes , remainingRetries )
342
347
}
343
348
344
349
func copyQuotas (in []corev1.ResourceQuota ) ([]corev1.ResourceQuota , error ) {
@@ -723,3 +728,13 @@ func hasUsageStats(resourceQuota *corev1.ResourceQuota, interestingResources []c
723
728
}
724
729
return true
725
730
}
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