Skip to content

feat(trigger): adding certificate request backoff duration to trigger controller#8312

Merged
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
hjoshi123:feat/cert-backoff-duration
Dec 23, 2025
Merged

feat(trigger): adding certificate request backoff duration to trigger controller#8312
cert-manager-prow[bot] merged 2 commits into
cert-manager:masterfrom
hjoshi123:feat/cert-backoff-duration

Conversation

@hjoshi123

@hjoshi123 hjoshi123 commented Dec 7, 2025

Copy link
Copy Markdown
Collaborator

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

Added `certificateRequestMinimumBackoffDuration` to controller configuration, for users who want cert-manager to retry  failed certificate requests faster. The default remains 1 hour.

CyberArk tracker: VC-47963

@cert-manager-prow cert-manager-prow Bot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/bug Categorizes issue or PR as related to a bug. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. area/api Indicates a PR directly modifies the 'pkg/apis' directory size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Dec 7, 2025
@hjoshi123
hjoshi123 force-pushed the feat/cert-backoff-duration branch from d28ee38 to e038077 Compare December 7, 2025 21:19
@hjoshi123

Copy link
Copy Markdown
Collaborator Author
image @wallrj-cyberark Validated that the cert back off duration works with a minute backoff in a kind cluster.

/cc @wallrj-cyberark

@wallrj-cyberark wallrj-cyberark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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 failure
kind 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"

Comment thread internal/apis/config/controller/v1alpha1/testdata/defaults.json
Comment thread internal/apis/config/controller/v1alpha1/defaults_test.go Outdated

// CertificateRequestBackoffDuration configures the initial backoff duration
// when a certificate request fails.
CertificateRequestBackoffDuration *sharedv1alpha1.Duration `json:"certificateRequestBackoffDuration,omitempty"`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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:

_

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Yeah I did think of adding it but based on the other fields not adding it, I thought of abiding by the convention

Comment thread pkg/apis/config/controller/v1alpha1/types.go Outdated
Comment thread pkg/controller/certificates/trigger/trigger_controller.go Outdated
Comment thread pkg/controller/certificates/trigger/trigger_controller.go
delay = initialDelay * time.Duration(math.Pow(2, float64(failedIssuanceAttempts-1)))
}

// Ensure that maximum returned delay is 32 hours

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

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.

Comment thread pkg/controller/certificates/trigger/trigger_controller.go
Comment thread pkg/controller/certificates/trigger/trigger_controller.go Outdated
@hjoshi123
hjoshi123 force-pushed the feat/cert-backoff-duration branch from e038077 to db4bee0 Compare December 23, 2025 04:41
@hjoshi123
hjoshi123 force-pushed the feat/cert-backoff-duration branch 2 times, most recently from 227631e to de02537 Compare December 23, 2025 05:20
@cert-manager-prow cert-manager-prow Bot added the area/testing Issues relating to testing label Dec 23, 2025
@wallrj-cyberark

Copy link
Copy Markdown
Member

/retest

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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 CertificateRequestMinimumBackoffDuration configuration 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.

Comment thread cmd/controller/app/options/options.go Outdated
ACMEDNS01Config ACMEDNS01Config `json:"acmeDNS01Config,omitempty"`

// CertificateRequestMinimumBackoffDuration configures the initial backoff duration
// when a certificate request fails.

Copilot AI Dec 23, 2025

Copy link

Choose a reason for hiding this comment

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

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."

Suggested change
// 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.

Copilot uses AI. Check for mistakes.
Comment thread pkg/controller/certificates/trigger/trigger_controller.go Outdated
Comment thread cmd/controller/app/options/options.go Outdated
Comment thread pkg/controller/certificates/trigger/trigger_controller.go Outdated
Comment thread pkg/controller/context.go Outdated
Comment thread internal/apis/config/controller/types.go Outdated
Comment thread internal/apis/config/controller/v1alpha1/defaults.go Outdated
Comment thread internal/apis/config/controller/v1alpha1/defaults.go Outdated
@wallrj-cyberark
wallrj-cyberark force-pushed the feat/cert-backoff-duration branch from c207198 to 7c79b0e Compare December 23, 2025 14:28
- 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>
@wallrj-cyberark
wallrj-cyberark force-pushed the feat/cert-backoff-duration branch from 7c79b0e to a4e3f45 Compare December 23, 2025 14:49
@hjoshi123

Copy link
Copy Markdown
Collaborator Author

/label tide/merge-method-squash

@cert-manager-prow cert-manager-prow Bot added the tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges. label Dec 23, 2025
Signed-off-by: hjoshi123 <mail@hjoshi.me>
@hjoshi123
hjoshi123 force-pushed the feat/cert-backoff-duration branch from b810bb6 to 5dc0e07 Compare December 23, 2025 15:31

@wallrj-cyberark wallrj-cyberark left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @hjoshi123

LGTM

@wallrj

wallrj commented Dec 23, 2025

Copy link
Copy Markdown
Member

/approve
/lgtm

@cert-manager-prow

Copy link
Copy Markdown
Contributor

[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

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

@cert-manager-prow cert-manager-prow Bot added lgtm Indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels Dec 23, 2025
@cert-manager-prow
cert-manager-prow Bot merged commit cac4f59 into cert-manager:master Dec 23, 2025
6 checks passed
@wallrj-cyberark wallrj-cyberark added the cybr Used by CyberArk-employed maintainers to report to line management what's being worked on. label Dec 23, 2025
bharath-b-rh pushed a commit to bharath-b-rh/jetstack-cert-manager that referenced this pull request Apr 6, 2026
… 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>
mytreya-rh pushed a commit to openshift/jetstack-cert-manager that referenced this pull request Jun 4, 2026
… 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>
mytreya-rh pushed a commit to mytreya-rh/jetstack-cert-manager that referenced this pull request Jun 9, 2026
… 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>
mytreya-rh pushed a commit to mytreya-rh/jetstack-cert-manager that referenced this pull request Jun 9, 2026
… 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>
mytreya-rh pushed a commit to openshift/jetstack-cert-manager that referenced this pull request Jun 9, 2026
… 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>
mytreya-rh pushed a commit to openshift/jetstack-cert-manager that referenced this pull request Jul 22, 2026
… 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>
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/api Indicates a PR directly modifies the 'pkg/apis' directory area/testing Issues relating to testing cybr Used by CyberArk-employed maintainers to report to line management what's being worked on. dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. kind/bug Categorizes issue or PR as related to a bug. lgtm Indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Request to reduce initial retry backoff for failed CertificateRequest

4 participants