Skip to content

Use renew trigger window instead of static renew time#145

Merged
cert-manager-prow[bot] merged 1 commit into
mainfrom
renewal_window
Feb 2, 2026
Merged

Use renew trigger window instead of static renew time#145
cert-manager-prow[bot] merged 1 commit into
mainfrom
renewal_window

Conversation

@inteon

@inteon inteon commented Jan 27, 2026

Copy link
Copy Markdown
Member

Select random renewal time between 6/10 and 7/10 of certificate lifetime.

This reduces the load of all controllers generating their (leaf) certificate at the same time.
If CA rotation is not leader-election protected (eg. in #129), this also reduces contention on CA renewal.

@cert-manager-prow cert-manager-prow Bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 27, 2026
@inteon inteon requested a review from Copilot January 27, 2026 12:39
@inteon

inteon commented Jan 27, 2026

Copy link
Copy Markdown
Member Author

/approve

@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: inteon

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@cert-manager-prow cert-manager-prow Bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jan 27, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR replaces the static certificate renewal time (at 2/3 of certificate lifetime) with a randomized renewal window (between 6/10 and 7/10 of lifetime). This change helps distribute certificate renewal load across controllers and reduces contention during CA rotation.

Changes:

  • Introduced TriggerWindow type with random time selection within a renewal window
  • Updated CA and leaf certificate controllers to use randomized renewal scheduling
  • Adjusted test cases to reflect the new 60% renewal threshold

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
internal/certificate/renew.go Replaced RenewAfter function with RenewTriggerWindow function that returns a time window (6/10 to 7/10 of lifetime) and added Random() method for selecting a random renewal time
pkg/authority/ca_secret_controller.go Updated to use new randomized renewal window API for both scheduling requeues and checking if regeneration is required
pkg/authority/leaf_cert_controller.go Updated to use new randomized renewal window API for scheduling requeues
pkg/authority/ca_secret_controller_test.go Updated test cases to verify the new 60% renewal threshold instead of the old 66.67% threshold

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/authority/ca_secret_controller.go Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/certificate/renew.go
Comment thread pkg/authority/leaf_cert_controller.go
Comment thread pkg/authority/ca_secret_controller.go
Comment thread internal/certificate/renew.go
Signed-off-by: Tim Ramlot <42113979+inteon@users.noreply.github.com>
@cert-manager-prow cert-manager-prow Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jan 27, 2026
Comment thread internal/certificate/renew.go
Comment thread pkg/authority/ca_secret_controller.go

@erikgb erikgb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

/lgtm

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Feb 2, 2026
@cert-manager-prow cert-manager-prow Bot merged commit 995e503 into main Feb 2, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. lgtm Indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants