fix(renew): Do not renew a certificate if its renewPolicy=Disabled - #9032
Conversation
|
Hi @sklirg. Thanks for your PR. I'm waiting for a cert-manager member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
Note: This does not "fix" the nil issue mentioned in #9031, caused by the fact that I'm not sure what the expected behavior for the caller is if the function returns renewalTime, err := pki.RenewalTime(notBefore.Time, notAfter.Time, crt.Spec.RenewBefore, crt.Spec.RenewBeforePercentage, crt.Spec.Renewal)
if err != nil {
reason = WindowError
message = err.Error()
} else if renewalTime == nil {
return "", "", false
}? |
|
Thank you for catching the edge case @sklirg.. I have a minor nit other than that the PR looks good to me. |
a0e7bf5 to
f4ba073
Compare
|
/ok-to-test |
This should be fine because the only case where the renewal time and error are nil is when the policy is disabled.. in all other cases we return either one of those |
Signed-off-by: Håkon Solbjørg <hakon@solbj.org>
41161e5 to
510f99b
Compare
Signed-off-by: Håkon Solbjørg <hakon@solbj.org>
510f99b to
c06e0bd
Compare
|
/retest |
Signed-off-by: Hemant Joshi <mail2hemantjoshi@pm.me>
|
/label tide/merge-method-squash |
|
/cherry-pick release-1.21 |
|
@wallrj-cyberark: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
There was a problem hiding this comment.
Pull request overview
This PR updates the certificate trigger policy evaluation to short-circuit renewal when a Certificate sets spec.renewal.policy=Disabled, preventing a nil dereference panic during renewal-time evaluation.
Changes:
- Add an early return in
CurrentCertificateNearingExpiryto skip renewal when the renewal policy isDisabled. - Introduce a new policy reason constant intended to represent “renewal disabled”.
- Add a trigger policy chain unit test case covering the disabled renewal policy scenario.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/controller/certificates/policies/constants.go | Adds a new policy reason constant for the “renewal disabled” scenario. |
| internal/controller/certificates/policies/checks.go | Skips renewal evaluation when spec.renewal.policy is Disabled. |
| internal/controller/certificates/policies/checks_test.go | Adds a unit test ensuring disabled renewal policy does not trigger reissuance (and avoids panic). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
/retest |
cert-manager#9032 (comment) Signed-off-by: Håkon Solbjørg <hakon@solbj.org>
|
/retest Looks like an infra flake, not related to this change — the failed e2e-v1-36 run shows a broad cluster-wide cascade (unrelated Certificates/CSR/Vault/ARI tests all timing out simultaneously, then ~1.8k |
wallrj-cyberark
left a comment
There was a problem hiding this comment.
Verified: the fix correctly short-circuits before the nil-pointer dereference (confirmed by tracing pki.RenewalTime returning (nil, nil) for CertificateRenewalPolicyDisabled), the added test would panic without the fix, and both Copilot findings have been resolved (one addressed by the suggested-change fix, one already deliberately settled by @hjoshi123 earlier in review). CI is green across all four jobs plus DCO; the earlier e2e-v1-36 failure was a cluster-wide infra flake (unrelated tests cascading from a dead API server connection), not a regression — confirmed by a clean retest.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: wallrj, wallrj-cyberark The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
For anyone following this from the release notes: I've opened cert-manager/website#2210, which adds worked, realistic scenarios to the renewal policies documentation — including an example of using |
|
@wallrj-cyberark: new pull request created: #9038 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
#9032 (comment) Signed-off-by: Håkon Solbjørg <hakon@solbj.org>
Pull Request Motivation
Fixes #9031
Kind
/kind bug
Release Note