From 0e0d1bc9b1ba930384214821b88d653927d55d96 Mon Sep 17 00:00:00 2001 From: Arkadiusz Galwas Date: Tue, 24 Oct 2023 16:18:12 +0200 Subject: [PATCH] Fix in rotation problem. --- internal/controller/gardener_cluster_controller.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/controller/gardener_cluster_controller.go b/internal/controller/gardener_cluster_controller.go index 835dceee..5ea16fff 100644 --- a/internal/controller/gardener_cluster_controller.go +++ b/internal/controller/gardener_cluster_controller.go @@ -239,6 +239,8 @@ func secretNeedsToBeRotated(cluster *imv1.GardenerCluster, secret *corev1.Secret } func secretRotationTimePassed(secret *corev1.Secret, rotationPeriod time.Duration) bool { + const rotationPeriodRatio = 0.95 + if secret == nil { return true } @@ -259,7 +261,7 @@ func secretRotationTimePassed(secret *corev1.Secret, rotationPeriod time.Duratio now := time.Now() alreadyValidFor := now.Sub(lastSyncTime) - return alreadyValidFor.Minutes() >= rotationPeriod.Minutes() + return alreadyValidFor.Minutes() >= rotationPeriodRatio*rotationPeriod.Minutes() } func secretRotationForced(cluster *imv1.GardenerCluster) bool {