Conversation
…certificate lifetime Signed-off-by: somaz <genius5711@gmail.com>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Hi @somaz94. 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. |
|
@somaz94 Thank you for picking this up but I feel i need to push back here. I don't really like the approach here and feels like there are a lot of factors that have not been thought through. I would love to know what made you take this approach. For example:
A naive validation is easy to implement here but something like this it has the ability to break both valid and invalid ones for the wrong reasons. I am not saying that validation is a bad thing, I get the issue but we need to be careful and thoughtful before we add such strict validations. I also feel, if we are to fix the behavior mentioned in the bug we could look at readiness controller too to see how we can gracefully retry the renewal mechanism. Long term that is the better option than stricter validation in my opinion. I understand that this was an AI assisted PR but I would prefer to understand your thought process on the PR and how you think this mechanism should work ideally. |
|
Fair pushback, and I think you're right on both counts. The approach came from the issue rather than from me. #9146 suggested an admission feasibility check on the grounds that The union point is right as well. I validate each window on its own, while The one piece I would still argue for is the cron that matches no date at all, like On how it should work ideally, I now agree with you that this belongs in the renewal path rather than in admission. Admission cannot see the value the decision actually depends on, so a check there is guessing, and guessing wrong in both directions is worse than not checking at all. I am happy to cut this down to the never matches case, or to close it and look at graceful retry in the readiness and trigger controllers instead. Which would you prefer? |
Pull Request Motivation
Closes #9146.
spec.renewal.windowsis validated for cron syntax, timezone and the presence ofwindowDuration, but not for whether a window is reachable at all. A 1 hour certificate with cron0 0 * * *andwindowDuration: 1mis admitted today, and then every reconcile fails to find a window: readiness keeps it atReady=Falsewith reasonWindowError, and the trigger controller renews outside the windows anyway.applyRenewBeforeWithWindowslooks for a window start in[notBefore-windowDuration, notAfter+windowDuration), soduration + 2*windowDurationis the widest range a start can fall into. The webhook now measures the shortest gap between cron activations and rejects the window when it is longer than that range, since hitting it would otherwise depend on where the certificate's validity happens to fall. A cron that never matches a date, like0 0 30 2 *, is rejected as well.Existing objects keep working: the check is skipped on update while
spec.durationandspec.renewalare unchanged, the same wayallowLegacyRenewBeforePercentageOnUpdatedoes it.This does not overlap #9109, which fixes the panic on the trigger path. That one is the crash, this one is the class of specs that reach the error. They do touch the same file, so I can rebase whenever #9109 lands.
Locally:
go test ./internal/...plus the pki, certificates controller and webhook packages pass, andgolangci-lint runon the changed package with the pinned v2.13.2 reports 0 issues. The new tests fail without the production change.Written with Claude Code (Opus 5).
Kind
/kind bug
Release Note