Skip to content

Commit

Permalink
fix divide by zero on looking up resource quota for uninitialized issuer
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinWeindel committed Sep 13, 2021
1 parent 1b30c7e commit e70e280
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/controller/issuer/certificate/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,12 @@ func (r *certReconciler) obtainCertificateAndPendingACME(logctx logger.LogContex
}

if accepted, requestsPerDayQuota := r.support.TryAcceptCertificateRequest(issuerKey); !accepted {
waitMinutes := 1440 / requestsPerDayQuota / 2
waitMinutes := 1
if requestsPerDayQuota == 0 {
err := fmt.Errorf("request quota lookup failed for issuer %s. Retrying in %d min. ", waitMinutes, issuerKey)
return r.recheck(logctx, obj, api.StatePending, err, time.Duration(waitMinutes)*time.Minute)
}
waitMinutes = 1440 / requestsPerDayQuota / 2
if waitMinutes < 5 {
waitMinutes = 5
}
Expand Down
2 changes: 2 additions & 0 deletions pkg/controller/issuer/core/support.go
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ func (s *Support) Failed(logger logger.LogContext, obj resources.Object, state s

// SucceededAndTriggerCertificates handles succeeded and trigger certificates.
func (s *Support) SucceededAndTriggerCertificates(logger logger.LogContext, obj resources.Object, itype *string, regRaw []byte) reconcile.Status {
s.RememberIssuerQuotas(obj.ClusterKey(), obj.Data().(*api.Issuer).Spec.RequestsPerDayQuota)

s.reportAllCertificateMetrics()
s.triggerCertificates(logger, s.ToIssuerKey(obj.ClusterKey()))

Expand Down

0 comments on commit e70e280

Please sign in to comment.