Feature/add annotation for renewBefore path on ingress / gateway#662
Feature/add annotation for renewBefore path on ingress / gateway#662titanlien wants to merge 4 commits intogardener:masterfrom
Conversation
|
[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 |
|
Welcome @titanlien! |
|
Hi @titanlien. Thanks for your PR. I'm waiting for a gardener member to verify that this patch is reasonable to test. If it is, they should reply with 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. |
|
/ok-to-test |
|
/test pull-cert-management-e2e-kind |
|
@titanlien /hold |
9980929 to
87a9e25
Compare
marc1404
left a comment
There was a problem hiding this comment.
Thank you for your contribution, @titanlien! 🙏
I left a few suggestions below. One general feedback: I appreciate that you split up changes into multiple commits. However, the second commit's message says it's about adding test code, while it also adjusts documentation and examples and adds logic to the certman2 code. It would've been nice to separate this more clearly (although it's totally manageable for the size of this changeset).
30696ad to
3a81b99
Compare
|
/ok-to-test |
3a81b99 to
ae535c6
Compare
|
/ok-to-test |
marc1404
left a comment
There was a problem hiding this comment.
Thanks for restructuring the commit history! 🙏
|
/unhold |
|
Successfully reached out to cla-assistant.io to initialize recheck of PR #662 |
852a8c4 to
5530faa
Compare
|
/ok-to-test |
5530faa to
37799e2
Compare
|
/ok-to-test |
|
@titanlien fyi: the |
There was a problem hiding this comment.
Hopefully the last feedback round 🤞
Please see my comment here.
ℹ️ One small note: For reviewers, it's convenient if you keep comments unresolved. That way reviewers can easily come back and compare open comments to further changes being made :)
Update examples/40-ingress-echoheaders.yaml Co-authored-by: Marc Vornetran <marc1404@users.noreply.github.com>
37799e2 to
47a328c
Compare
| // DefaultRenewBefore is the default renewBefore duration (720 hours / 30 days) | ||
| DefaultRenewBefore = 720 * time.Hour |
There was a problem hiding this comment.
I don't see this value being used anywhere else, it appears to be unused
| renewBefore := annotations[AnnotRenewBefore] | ||
|
|
||
| certInput.FollowCNAME = followCNAME | ||
| certInput.IssuerName = issuer | ||
| certInput.PreferredChain = preferredChain | ||
| certInput.PrivateKeyAlgorithm = algorithm | ||
| certInput.PrivateKeySize = keySize | ||
| certInput.PrivateKeyEncoding = encoding | ||
| certInput.RenewBefore = renewBefore |
There was a problem hiding this comment.
nit: I don't see the local variable renewBefore being used anywhere else. What about inlining it?
| renewBefore := annotations[AnnotRenewBefore] | |
| certInput.FollowCNAME = followCNAME | |
| certInput.IssuerName = issuer | |
| certInput.PreferredChain = preferredChain | |
| certInput.PrivateKeyAlgorithm = algorithm | |
| certInput.PrivateKeySize = keySize | |
| certInput.PrivateKeyEncoding = encoding | |
| certInput.RenewBefore = renewBefore | |
| certInput.FollowCNAME = followCNAME | |
| certInput.IssuerName = issuer | |
| certInput.PreferredChain = preferredChain | |
| certInput.PrivateKeyAlgorithm = algorithm | |
| certInput.PrivateKeySize = keySize | |
| certInput.PrivateKeyEncoding = encoding | |
| certInput.RenewBefore = annotations[AnnotRenewBefore] |
|
|
||
| api "github.com/gardener/cert-management/pkg/apis/cert/v1alpha1" | ||
| "github.com/gardener/cert-management/pkg/cert/source" | ||
| "github.com/gardener/cert-management/pkg/certman2/controller/source/common" |
There was a problem hiding this comment.
This wasn't visible before I approved the workflow runs: There are currently two code branches in this repository. Everything in pkg/certman2 is a rewrite of the project using controller-runtime. Everything outside is the legacy codebase. We've added .import-restrictions files to catch unintentional cross-imports between these branches.
This change violates the import restriction:
ERROR: "github.com/gardener/cert-management/pkg/controller/source" -> "github.com/gardener/cert-management/pkg/certman2/controller/source/common" is forbidden by cert-management/pkg/controller/.import-restrictions
make: *** [check-imports] Error 1
Shared utilities should be moved to pkg/shared
| // Returns (nil, warning) if the string is invalid or the duration is less than 5 minutes. | ||
| // Returns (nil, "") if the string is empty. | ||
| // The default value of DefaultRenewBefore is applied by the certificate controller if nil is returned. | ||
| func ParseRenewBefore(renewBeforeStr string) (*metav1.Duration, string) { |
There was a problem hiding this comment.
Please add unit tests for this function
| // Returns (nil, warning) if the string is invalid or the duration is less than 5 minutes. | ||
| // Returns (nil, "") if the string is empty. | ||
| // The default value of DefaultRenewBefore is applied by the certificate controller if nil is returned. | ||
| func ParseRenewBefore(renewBeforeStr string) (*metav1.Duration, string) { |
There was a problem hiding this comment.
I'm not too happy with the returned string for the warning message; let's return a proper Go error instead. The callers can then decide what to do with the error value (discard and fallback to default value or log when a logger is available)
| func ParseRenewBefore(renewBeforeStr string) (*metav1.Duration, string) { | |
| func ParseRenewBefore(renewBeforeStr string) (*metav1.Duration, error) { |
| PrivateKeyAlgorithm string | ||
| PrivateKeySize int | ||
| PrivateKeyEncoding string | ||
| RenewBefore string |
There was a problem hiding this comment.
I suggest not storing the raw annotation value in the CertInput struct; instead, parse it directly and handle it as a Duration. This would be aligned with how it was done in the legacy code branch
| RenewBefore string | |
| RenewBefore *metav1.Duration |
Co-authored-by: Marc Vornetran <marc1404@users.noreply.github.com>
|
The Gardener project currently lacks enough active contributors to adequately respond to all PRs.
You can:
/lifecycle stale |
How to categorize this PR?
/kind enhancement
What this PR does / why we need it:
Partially fix the renew window, we can increase renewBefore from 30days to 60 days.
Which issue(s) this PR fixes:
Related to #475
Special notes for your reviewer:
We can use annotation on ingress / gateway resource to define the renewBefore on certificates
Release note: