diff --git a/cmd/expiration-mailer/main.go b/cmd/expiration-mailer/main.go index a5a42db78..f6b02976e 100644 --- a/cmd/expiration-mailer/main.go +++ b/cmd/expiration-mailer/main.go @@ -296,6 +296,21 @@ func (m *mailer) findExpiringCertificates() error { return err } + // If the number of rows was exactly `m.limit` rows we need to increment + // a stat indicating that this nag group is at capacity based on the + // configured cert limit. If this condition continually occurs across mailer + // runs then we will not catch up, resulting in under-sending expiration + // mails. The effects of this were initially described in issue #2002[0]. + // + // 0: https://github.com/letsencrypt/boulder/issues/2002 + atCapacity := float64(0) + if len(serials) == m.limit { + m.log.Infof("nag group %s expiring certificates at configured capacity (select limit %d)", + expiresIn.String(), m.limit) + atCapacity = float64(1) + } + m.stats.nagsAtCapacity.With(prometheus.Labels{"nag_group": expiresIn.String()}).Set(atCapacity) + // Now we can sequentially retrieve the certificate details for each of the // certificate status rows var certs []core.Certificate @@ -319,21 +334,6 @@ func (m *mailer) findExpiringCertificates() error { m.log.Infof("Found %d certificates expiring between %s and %s", len(certs), left.Format("2006-01-02 03:04"), right.Format("2006-01-02 03:04")) - // If the `certs` result was exactly `m.limit` rows we need to increment - // a stat indicating that this nag group is at capacity based on the - // configured cert limit. If this condition continually occurs across mailer - // runs then we will not catch up, resulting in under-sending expiration - // mails. The effects of this were initially described in issue #2002[0]. - // - // 0: https://github.com/letsencrypt/boulder/issues/2002 - atCapacity := float64(0) - if len(certs) == m.limit { - m.log.Infof("nag group %s expiring certificates at configured capacity (cert limit %d)", - expiresIn.String(), m.limit) - atCapacity = float64(1) - } - m.stats.nagsAtCapacity.With(prometheus.Labels{"nag_group": expiresIn.String()}).Set(atCapacity) - if len(certs) == 0 { continue // nothing to do }