From 94048afd001fd960f316e961501b871ab648296e Mon Sep 17 00:00:00 2001 From: Jack Wotherspoon Date: Mon, 27 Feb 2023 16:46:59 -0500 Subject: [PATCH] fix: strip monotonic clock readings for refresh calculations (#471) --- internal/cloudsql/instance.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/cloudsql/instance.go b/internal/cloudsql/instance.go index bfeaaf64..021217dd 100644 --- a/internal/cloudsql/instance.go +++ b/internal/cloudsql/instance.go @@ -115,7 +115,7 @@ func (r *refreshOperation) isValid() bool { default: return false case <-r.ready: - if r.err != nil || time.Now().After(r.expiry) { + if r.err != nil || time.Now().After(r.expiry.Round(0)) { return false } return true @@ -301,7 +301,7 @@ func (i *Instance) result(ctx context.Context) (*refreshOperation, error) { // refresh. Usually that duration will be half of the time until certificate // expiration. func refreshDuration(now, certExpiry time.Time) time.Duration { - d := certExpiry.Sub(now) + d := certExpiry.Sub(now.Round(0)) if d < time.Hour { // Something is wrong with the certificate, refresh now. if d < refreshBuffer {