From 6f4f51cc9f2bb79e55f41f68482ea3875df7f3f7 Mon Sep 17 00:00:00 2001 From: Jeff Mitchell Date: Sat, 20 May 2023 08:24:56 -0400 Subject: [PATCH] Fix display of next rotation time (#3236) --- internal/daemon/worker/auth_rotation.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/daemon/worker/auth_rotation.go b/internal/daemon/worker/auth_rotation.go index 5add09b226..1e33fac5e1 100644 --- a/internal/daemon/worker/auth_rotation.go +++ b/internal/daemon/worker/auth_rotation.go @@ -155,6 +155,9 @@ func (w *Worker) startAuthRotationTicking(cancelCtx context.Context) { // halfway through the current rotation interval now := time.Now().UTC() nextRotation := lastRotation.Add(rotationInterval / 2) + if lastRotation.IsZero() { + nextRotation = now + } event.WriteSysEvent(cancelCtx, op, "checking if worker auth should rotate", append( args, "now", now.Format(time.RFC3339), @@ -176,7 +179,7 @@ func (w *Worker) startAuthRotationTicking(cancelCtx context.Context) { event.WriteError(cancelCtx, op, err) continue } - lastRotation := now + lastRotation = now nextRotation = lastRotation.Add(newRotationInterval / 2) resetDuration = nextRotation.Sub(now) event.WriteSysEvent(cancelCtx, op, "worker credentials rotated", "next_rotation", nextRotation)