feat(trigger): adding certificate request backoff duration to trigger controller#8312
Conversation
d28ee38 to
e038077
Compare
@wallrj-cyberark Validated that the cert back off duration works with a minute backoff in a kind cluster.
/cc @wallrj-cyberark |
There was a problem hiding this comment.
Thanks @hjoshi123
It's looking good. I left a few comments and suggestions.
I also tested it locally and I think I could see it working, by manually "denying" the CertificateRequests using cmctl and observing the time taken for cert-manager to create a new CertificateRequest.
But it was quite confusing because cert-manager seems to log multiple messages about the when it will next attempt ....and it seemed to log the messages BEFORE I manually denied the CR using cmctl.
I deploye cert-manager built from this branch, as follows:
# values.yaml
config:
logging:
verbosity: 4
format: text
certificateRequestBackoffDuration: 10s
disableAutoApproval: true # So that I can simulate a certificate request denied failurekind create cluster
$ make ko-deploy-certmanager KO_HELM_VALUES_FILES=$PWD/values.yaml
...
# test-resources.yaml
Version: cert-manager.io/v1
kind: Certificate
metadata:
name: test1
spec:
dnsNames:
- example.com
secretName: test1-tls
revisionHistoryLimit: 10
issuerRef:
name: test1
kubectl apply -f test-resources.yaml
cmctl deny test1-1
I1218 18:01:20.146674 1 trigger_controller.go:206] "Backing off from issuance due to previously failed issuance(s). Issuance will next be attempted at 2025-12-18 18:04:00.00000124 +0000 UTC m=+500.094002990" logger="cert-manager.controller" key="default/test1"
I1218 18:01:20.147362 1 trigger_controller.go:206] "Backing off from issuance due to previously failed issuance(s). Issuance will next be attempted at 2025-12-18 18:04:00.000000781 +0000 UTC m=+500.094002529" logger="cert-manager.controller" key="default/test1"
I1218 18:04:00.142896 1 trigger_controller.go:206] "Backing off from issuance due to previously failed issuance(s). Issuance will next be attempted at 2025-12-18 18:09:20.000001773 +0000 UTC m=+820.094003544" logger="cert-manager.controller" key="default/test1"
I1218 18:04:00.167329 1 trigger_controller.go:206] "Backing off from issuance due to previously failed issuance(s). Issuance will next be attempted at 2025-12-18 18:09:20.000002455 +0000 UTC m=+820.094004218" logger="cert-manager.controller" key="default/test1"
I1218 18:04:00.174196 1 trigger_controller.go:206] "Backing off from issuance due to previously failed issuance(s). Issuance will next be attempted at 2025-12-18 18:09:20.000002525 +0000 UTC m=+820.094004290" logger="cert-manager.controller" key="default/test1"
I1218 18:04:19.982770 1 trigger_controller.go:206] "Backing off from issuance due to previously failed issuance(s). Issuance will next be attempted at 2025-12-18 18:09:20.000003191 +0000 UTC m=+820.094004962" logger="cert-manager.controller" key="default/test1"
|
|
||
| // CertificateRequestBackoffDuration configures the initial backoff duration | ||
| // when a certificate request fails. | ||
| CertificateRequestBackoffDuration *sharedv1alpha1.Duration `json:"certificateRequestBackoffDuration,omitempty"` |
There was a problem hiding this comment.
I was about to suggest documenting the default value here, but I see that none of the other fields document the defaults and the defaults are not rendered in the API docs:
It must be difficult for users to know what the defaults are, without running the controller with --help or by looking at the CLI reference docs:
_
There was a problem hiding this comment.
Yeah I did think of adding it but based on the other fields not adding it, I thought of abiding by the convention
| delay = initialDelay * time.Duration(math.Pow(2, float64(failedIssuanceAttempts-1))) | ||
| } | ||
|
|
||
| // Ensure that maximum returned delay is 32 hours |
There was a problem hiding this comment.
Will the maximum still be 32 hours, if I choose a much shorter initial delay? Or is there a maximum number of retries which will be hit first?
Update all these comments.
There's a comment below which talks about guarding agains "maths misuse". Any idea what that's about?
There was a problem hiding this comment.
I think its about the integer overflow that happens at 2 ^ 99 and we are guarding against that. In the scenario where it overflows then delay's value would be unpredictable and hence we would want to return the default value of initialDelay but ofc it wont be 1 hour in this case since its configurable.
There was a problem hiding this comment.
Also, I feel the maximum should still be the same? It will for sure hit the max retries first and then return the max delay.
e038077 to
db4bee0
Compare
227631e to
de02537
Compare
|
/retest |
There was a problem hiding this comment.
Pull request overview
This PR adds a configurable certificateRequestBackoffDuration field to the controller configuration, addressing issue #8259 where the backoff duration was hardcoded to 1 hour with no way for users to customize it.
Key Changes:
- Added
CertificateRequestMinimumBackoffDurationconfiguration field with a default value of 1 hour - Modified the trigger controller to use the configurable backoff duration instead of the hardcoded value
- Added comprehensive test coverage for the new configurable backoff behavior
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
pkg/apis/config/controller/v1alpha1/types.go |
Adds the new CertificateRequestMinimumBackoffDuration field to the public API configuration struct |
internal/apis/config/controller/types.go |
Adds the internal representation of the CertificateRequestMinimumBackoffDuration field |
internal/apis/config/controller/v1alpha1/defaults.go |
Sets the default value for the new field to 1 hour (maintaining backward compatibility) |
internal/apis/config/controller/v1alpha1/testdata/defaults.json |
Updates test data to include the default backoff duration |
internal/apis/config/controller/v1alpha1/zz_generated.conversion.go |
Adds generated conversion code for the new field |
pkg/apis/config/controller/v1alpha1/zz_generated.deepcopy.go |
Adds generated deep copy code for the new pointer field |
pkg/controller/context.go |
Adds the CertificateRequestMinimumBackoffDuration field to CertificateOptions |
cmd/controller/app/options/options.go |
Adds CLI flag --certificate-request-backoff-duration for configuration |
cmd/controller/app/controller.go |
Wires the configuration value to the controller context |
pkg/controller/certificates/trigger/trigger_controller.go |
Updates the controller to use the configurable backoff duration and modifies the shouldBackoffReissuingOnFailure function signature |
pkg/controller/certificates/trigger/trigger_controller_test.go |
Adds test coverage for custom backoff durations and updates existing tests to use the new parameter |
test/integration/certificates/trigger_controller_test.go |
Sets the default backoff duration in integration tests |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ACMEDNS01Config ACMEDNS01Config `json:"acmeDNS01Config,omitempty"` | ||
|
|
||
| // CertificateRequestMinimumBackoffDuration configures the initial backoff duration | ||
| // when a certificate request fails. |
There was a problem hiding this comment.
The comment documentation is too brief and doesn't adequately describe the behavior. It states "configures the initial backoff duration when a certificate request fails" but doesn't explain that this duration is exponentially increased based on consecutive failures or that it represents the minimum backoff. Consider revising to: "CertificateRequestMinimumBackoffDuration configures the initial backoff duration when a certificate request fails. This duration is exponentially increased (up to a maximum of 32 hours) based on the number of consecutive failures."
| // when a certificate request fails. | |
| // when a certificate request fails. This duration is exponentially increased | |
| // (up to a maximum of 32 hours) based on the number of consecutive failures. |
c207198 to
7c79b0e
Compare
- Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com>
7c79b0e to
a4e3f45
Compare
|
/label tide/merge-method-squash |
Signed-off-by: hjoshi123 <mail@hjoshi.me>
b810bb6 to
5dc0e07
Compare
wallrj-cyberark
left a comment
There was a problem hiding this comment.
Thanks @hjoshi123
LGTM
|
/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 |
… controller (cert-manager#8312) * Add configurable initial certificate request backoff - Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com> * attempt to fix test with default backoff Signed-off-by: hjoshi123 <mail@hjoshi.me> --------- Signed-off-by: Hemant Joshi <mail@hjoshi.me> Signed-off-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: hjoshi123 <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com>
… controller (cert-manager#8312) * Add configurable initial certificate request backoff - Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com> * attempt to fix test with default backoff Signed-off-by: hjoshi123 <mail@hjoshi.me> --------- Signed-off-by: Hemant Joshi <mail@hjoshi.me> Signed-off-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: hjoshi123 <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com>
… controller (cert-manager#8312) * Add configurable initial certificate request backoff - Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com> * attempt to fix test with default backoff Signed-off-by: hjoshi123 <mail@hjoshi.me> --------- Signed-off-by: Hemant Joshi <mail@hjoshi.me> Signed-off-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: hjoshi123 <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com>
… controller (cert-manager#8312) * Add configurable initial certificate request backoff - Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com> * attempt to fix test with default backoff Signed-off-by: hjoshi123 <mail@hjoshi.me> --------- Signed-off-by: Hemant Joshi <mail@hjoshi.me> Signed-off-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: hjoshi123 <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com>
… controller (cert-manager#8312) * Add configurable initial certificate request backoff - Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com> * attempt to fix test with default backoff Signed-off-by: hjoshi123 <mail@hjoshi.me> --------- Signed-off-by: Hemant Joshi <mail@hjoshi.me> Signed-off-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: hjoshi123 <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com>
… controller (cert-manager#8312) * Add configurable initial certificate request backoff - Add controller config field for initial certificate request backoff - Add CLI flag to configure the initial backoff duration - Use configured initial delay in trigger controller backoff - Default initial delay is 1h and backoff doubles per failure up to 32h - Update defaults, conversions, controller context, and tests Signed-off-by: Hemant Joshi <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: Richard Wall <richard.wall@cyberark.com> * attempt to fix test with default backoff Signed-off-by: hjoshi123 <mail@hjoshi.me> --------- Signed-off-by: Hemant Joshi <mail@hjoshi.me> Signed-off-by: Richard Wall <richard.wall@cyberark.com> Signed-off-by: hjoshi123 <mail@hjoshi.me> Co-authored-by: Richard Wall <richard.wall@cyberark.com>

Pull Request Motivation
This PR addresses the bug where the default backoff duration was configured to be 1 hour and users had no ability to configure them whatsoever. This bug is also captured in the issue #8259.
Kind
/kind bug
Release Note
CyberArk tracker: VC-47963