Skip to content

Commit

Permalink
fix: strip monotonic clock readings for refresh calculations (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
jackwotherspoon authored Feb 27, 2023
1 parent 2044105 commit 94048af
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions internal/cloudsql/instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down

0 comments on commit 94048af

Please sign in to comment.