Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: support shorter refresh durations #103

Merged
merged 6 commits into from
Sep 7, 2022
Merged

fix: support shorter refresh durations #103

merged 6 commits into from
Sep 7, 2022

Conversation

enocom
Copy link
Member

@enocom enocom commented Aug 23, 2022

No description provided.

@enocom enocom requested a review from a team August 23, 2022 21:38
Comment on lines 221 to 225
d := certExpiry.Sub(now)
if d <= time.Hour {
return 55 * time.Minute
}
return time.Until(now.Add(time.Duration(d / 2)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is quite what we want to do. If something odd happens and a certificate with a duration of less than 1 hour incurs, this will still wait 55 minutes to refresh that cert.

What we really want the logic to be is in the certExpiry is <= 1hr (although maybe ~65 minutes gives us a better margin of error) then we use a window of 5 minutes.

How about something like this:

// default window is half of the certs expected duration
w := time.Until(certExpiry) / 2
if w < time.Hour {
    w = 5 * time.Minute
}
return w

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've extended the edge case checking.

@enocom enocom requested a review from kurtisvg August 30, 2022 18:33
@enocom enocom merged commit 6f6a7a0 into main Sep 7, 2022
@enocom enocom deleted the refresh-duration branch September 7, 2022 00:12
enocom added a commit to GoogleCloudPlatform/cloud-sql-go-connector that referenced this pull request Nov 1, 2022
The change here updates the calculation of how long to wait before
starting a refresh cycle.

This is a port of GoogleCloudPlatform/alloydb-go-connector#103.
enocom added a commit to GoogleCloudPlatform/cloud-sql-go-connector that referenced this pull request Nov 2, 2022
The change here updates the calculation of how long to wait before
starting a refresh cycle.

This is a port of GoogleCloudPlatform/alloydb-go-connector#103.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants