From 95257d2ee189131ea45de99ad7827d6cc03ef8d7 Mon Sep 17 00:00:00 2001 From: smasset-orange <86793256+smasset-orange@users.noreply.github.com> Date: Tue, 26 Apr 2022 14:36:08 +0200 Subject: [PATCH] Fix RenewInterval computation in ACME provider --- pkg/provider/acme/provider.go | 2 +- pkg/provider/acme/provider_test.go | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/provider/acme/provider.go b/pkg/provider/acme/provider.go index bbc95d516..bdf59afd7 100644 --- a/pkg/provider/acme/provider.go +++ b/pkg/provider/acme/provider.go @@ -532,7 +532,7 @@ func (p *Provider) addCertificateForDomain(domain types.Domain, certificate, key // The second (RenewInterval) is the interval between renew attempts. func getCertificateRenewDurations(certificatesDuration int) (time.Duration, time.Duration) { switch { - case certificatesDuration >= 265*24: // >= 1 year + case certificatesDuration >= 365*24: // >= 1 year return 4 * 30 * 24 * time.Hour, 7 * 24 * time.Hour // 4 month, 1 week case certificatesDuration >= 3*30*24: // >= 90 days return 30 * 24 * time.Hour, 24 * time.Hour // 30 days, 1 day diff --git a/pkg/provider/acme/provider_test.go b/pkg/provider/acme/provider_test.go index 64bcf1085..103eff59e 100644 --- a/pkg/provider/acme/provider_test.go +++ b/pkg/provider/acme/provider_test.go @@ -608,11 +608,17 @@ func Test_getCertificateRenewDurations(t *testing.T) { expectRenewInterval: time.Minute, }, { - desc: "1 Year certificates: 2 months renew period, 1 week renew interval", + desc: "1 Year certificates: 4 months renew period, 1 week renew interval", certificatesDurations: 24 * 365, expectRenewPeriod: time.Hour * 24 * 30 * 4, expectRenewInterval: time.Hour * 24 * 7, }, + { + desc: "265 Days certificates: 30 days renew period, 1 day renew interval", + certificatesDurations: 24 * 265, + expectRenewPeriod: time.Hour * 24 * 30, + expectRenewInterval: time.Hour * 24, + }, { desc: "90 Days certificates: 30 days renew period, 1 day renew interval", certificatesDurations: 24 * 90,