Skip to content

Refactor the webhook dynamic source and add unit tests - #6784

Merged
jetstack-bot merged 3 commits into
cert-manager:masterfrom
inteon:fix_dynamic_source
Mar 12, 2024
Merged

jetstack-bot merged 3 commits into
cert-manager:masterfrom
inteon:fix_dynamic_source

Conversation

@inteon

@inteon inteon commented Feb 21, 2024 •

Copy link
Copy Markdown
Member
  • Adds unit tests to increase our confidence in the dynamic source logic.
  • Simplifies the source by replacing a lot of the channels with an errgroup

Kind

/kind cleanup

Release Note

NONE

@jetstack-bot jetstack-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. release-note-none Denotes a PR that doesn't merit a release note. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/testing Issues relating to testing size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Feb 21, 2024
@inteon inteon changed the title Improve the webhook dynamic source implementation and add a lot of unit tests Improve the webhook dynamic source implementation and add unit tests Feb 21, 2024
@inteon inteon changed the title Improve the webhook dynamic source implementation and add unit tests Refactor the webhook dynamic source and add unit tests Feb 21, 2024
for {
if done := func() bool {
timer := time.NewTimer(time.Until(renewMoment))
defer timer.Stop()

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

BUGFIX: This was a defer in a for loop.

@inteon
inteon force-pushed the fix_dynamic_source branch from d9cb984 to 2d2a6a5 Compare February 21, 2024 19:11
return true
}
// renew the root CA when the current one is 2/3 of the way through its life
if x509Cert.NotAfter.Sub(time.Now()) < (d.CADuration / 3) {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Instead of using d.CADuration, use the actual lifetime of the certificate.

Comment thread pkg/server/tls/authority/authority.go Resolved
Comment thread pkg/server/tls/authority/authority.go Resolved
Comment thread pkg/server/tls/dynamic_source.go Resolved
Comment thread pkg/server/tls/dynamic_source.go Resolved
Comment thread pkg/server/tls/dynamic_source.go Resolved
@inteon
inteon force-pushed the fix_dynamic_source branch from 2d2a6a5 to f4ae942 Compare March 11, 2024 18:22
Signed-off-by: Tim Ramlot <[email protected]>
@inteon
inteon requested a review from ThatsMrTalbot March 12, 2024 12:45
@ThatsMrTalbot

Copy link
Copy Markdown
Contributor

/lgtm

@jetstack-bot jetstack-bot added the lgtm Indicates that a PR is ready to be merged. label Mar 12, 2024
@inteon

inteon commented Mar 12, 2024

Copy link
Copy Markdown
Member Author

/approve

@jetstack-bot

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

@jetstack-bot jetstack-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 12, 2024
@jetstack-bot
jetstack-bot merged commit 3a26313 into cert-manager:master Mar 12, 2024
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. area/testing Issues relating to testing dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. lgtm Indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants