Skip to content

Re-queue Issuer/ClusterIssuer on ACME DNS-01 solver Secret events - #9042

Merged
cert-manager-prow[bot] merged 7 commits into
cert-manager:masterfrom
SebTardif:fix/issuer-solver-secret-rereconcile
Jul 29, 2026
Merged

cert-manager-prow[bot] merged 7 commits into
cert-manager:masterfrom
SebTardif:fix/issuer-solver-secret-rereconcile

Conversation

@SebTardif

Copy link
Copy Markdown
Contributor

Pull Request Motivation

Fixes #9036

Since #8255, ACME Issuer/ClusterIssuer Setup() validates DNS-01 solver Secrets and can leave the issuer at Ready: False / InvalidSolver when a Secret is missing. Creating that Secret later never re-queued the issuer because issuersForSecret only matched the ACME account private key and EAB key, not solver secretRefs. Recovery required a 10h resync, a spec change, or a restart.

Changes

  • Extend issuersForSecret in both pkg/controller/issuers and pkg/controller/clusterissuers to match DNS-01 solver secrets (same set of secret names collected by ValidateACMEChallengeSolverDNS01: Route53, CloudDNS, Cloudflare, Akamai, AzureDNS, AcmeDNS, DigitalOcean, RFC2136, etc.).
  • Keep matching private key and EAB secrets as before.
  • Unit tests for the pure matcher (account key, EAB, Route53, CloudDNS, unrelated secret).

Kind

/kind bug

Release Note

Fix Issuer/ClusterIssuer stuck at Ready=False/InvalidSolver after a missing ACME DNS-01 solver Secret is created

Verification

go test ./pkg/controller/issuers/ ./pkg/controller/clusterissuers/ -count=1

Both packages: pass (including new TestACMEIssuerReferencesSecret).

Related

issuersForSecret only matched the ACME account private key and EAB
secret. After cert-manager#8255, Setup() marks issuers InvalidSolver when a DNS-01
solver Secret is missing, but creating that Secret never re-queued the
Issuer. Match the same solver secretRefs ValidateACMEChallengeSolverDNS01
collects so Ready recovers without waiting for resync.

Fixes cert-manager#9036

Signed-off-by: Sebastien Tardif <[email protected]>
@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. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 17, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

Hi @SebTardif. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

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.

@cert-manager-prow cert-manager-prow Bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jul 17, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member

/ok-to-test

@cert-manager-prow cert-manager-prow Bot added ok-to-test and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jul 21, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member

Thanks for this — verified the root cause and fix locally, and it matches an independent reproduction on the issue from @gecube.

One suggestion for consideration, not a blocker: rather than hard-coding the DNS-01 provider secret names again in issuersForSecret(), it may be worth extracting the existing per-provider secret-reference walk already used by ValidateACMEChallengeSolverDNS01 into a small exported helper, and calling that from both issuersForSecret() implementations. That would keep the requeue-trigger list automatically in sync with the admission-validation path as new providers are added, rather than needing to be updated in two places. Happy to help with that as a follow-up if useful — not asking you to rework this PR for it.

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 fixes a cert-manager controller requeue gap where Issuer/ClusterIssuer ACME DNS-01 solver Secret creation/updates would not trigger reconciliation, leaving resources stuck Ready=False/InvalidSolver until a periodic resync or restart.

Changes:

  • Extend Secret-to-Issuer matching logic to include ACME DNS-01 solver Secret references (in addition to ACME account key and EAB key).
  • Add unit tests for the new ACME secret reference matcher in both issuer and clusterissuer controllers.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
pkg/controller/issuers/checks.go Requeue Issuers when a referenced ACME DNS-01 solver Secret changes.
pkg/controller/issuers/checks_test.go Unit tests covering account key, EAB, DNS-01 solver secrets, and unrelated secrets.
pkg/controller/clusterissuers/checks.go Requeue ClusterIssuers when a referenced ACME DNS-01 solver Secret changes.
pkg/controller/clusterissuers/checks_test.go Unit tests covering account key, EAB, DNS-01 solver secrets, and unrelated secrets.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread pkg/controller/issuers/checks.go Resolved
Comment thread pkg/controller/clusterissuers/checks.go Resolved
@cert-manager-prow cert-manager-prow Bot added area/acme Indicates a PR directly modifies the ACME Issuer code size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 22, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member

Thanks again for tracking down and fixing this, @SebTardif — since there hadn't been a chance to follow up on the refactor suggested above (and echoed independently by Copilot on both checks.go files), I've gone ahead and pushed a commit implementing it directly to this branch, since maintainer edits are enabled: 7991126.

What it does:

  • Adds pkg/acme.RequiredDNS01SolverSecrets, extracted from the existing extractSecrets() helper in pkg/issuer/acme (which already derives the DNS-01 solver secretRef list from ValidateACMEChallengeSolverDNS01 to check those Secrets exist).
  • Calls it from both issuersForSecret() implementations in place of the hand-written per-provider dns01SolverReferencesSecret/acmeIssuerReferencesSecret helpers, and from pkg/issuer/acme's validateDNSSolvers() in place of its own now-duplicate copy.
  • Replaces the two TestACMEIssuerReferencesSecret unit tests (which exercised the removed helper directly) with a higher-level TestIssuersForSecret_ACMEDNS01Solver regression test per controller, exercising issuersForSecret() end-to-end via a real lister — covering PrivateKey, EAB, DNS-01 solver, CA and cross-namespace/cross-scope cases.

Net effect is the same behaviour as your original commit, but a new DNS-01 provider's secretRefs now only need wiring into ValidateACMEChallengeSolverDNS01 once for both the admission-validation and requeue-trigger paths to pick them up, rather than needing the provider list updated in three places.

Verified locally: go build ./... and go test ./pkg/acme/... ./pkg/issuer/acme/... ./pkg/controller/issuers/... ./pkg/controller/clusterissuers/... all pass.

Feel free to build on top of this or push further changes to the branch as usual — happy to iterate further if you'd like a different approach.

@SebTardif

Copy link
Copy Markdown
Contributor Author

/retest-required

@wallrj-cyberark
wallrj-cyberark requested a review from wallrj July 22, 2026 14:18
@wallrj-cyberark

Copy link
Copy Markdown
Member

/cherry-pick release-1.21

@cert-manager-bot

Copy link
Copy Markdown
Contributor

@wallrj-cyberark: once the present PR merges, I will cherry-pick it on top of release-1.21 in a new PR and assign it to you.

Details

In response to this:

/cherry-pick release-1.21

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.

issuersForSecret() in pkg/controller/issuers and
pkg/controller/clusterissuers duplicated the per-provider DNS-01
solver secretRef list, both between the two controllers and relative
to the source of truth in ValidateACMEChallengeSolverDNS01. Flagged
independently by Copilot on both files and raised in review: this
risks drift if a DNS-01 provider's secretRefs change, potentially
reintroducing the stuck Ready=False/InvalidSolver behaviour from cert-manager#9036
for that provider.

Add pkg/acme.RequiredDNS01SolverSecrets, extracted from the existing
extractSecrets() helper in pkg/issuer/acme (which already derives the
same list from ValidateACMEChallengeSolverDNS01 for the purpose of
checking solver Secrets exist), and call it from both
issuersForSecret() implementations and from pkg/issuer/acme's
validateDNSSolvers(). A new DNS-01 provider's secretRefs now only need
wiring into ValidateACMEChallengeSolverDNS01 once for both the
admission-validation and requeue-trigger paths to pick them up.

Replace the two checks_test.go files' unit tests of the removed
per-provider matcher with a higher-level regression test exercising
issuersForSecret() end-to-end, covering PrivateKey, EAB, DNS-01 solver,
CA and cross-namespace/cross-scope cases.

Handle acme.RequiredDNS01SolverSecrets() errors per-issuer rather than
aborting issuersForSecret() entirely: converting one issuer's DNS-01
solver config to its internal type is not expected to fail in
practice, but propagating that error out of the whole function would
have blocked Secret-triggered requeueing for every other issuer too,
not just the one that failed to convert. Log and skip that issuer
instead, matching the existing pattern in
pkg/controller/acmeorders/checks.go.

Signed-off-by: Richard Wall <[email protected]>
@wallrj-cyberark
wallrj-cyberark force-pushed the fix/issuer-solver-secret-rereconcile branch from 7991126 to bdbde69 Compare July 22, 2026 15:33
TestRequiredDNS01SolverSecrets only exercised Route53 and CloudDNS,
even though the whole point of extracting RequiredDNS01SolverSecrets
was to keep the requeue-trigger secret list automatically in sync with
ValidateACMEChallengeSolverDNS01 as DNS-01 providers change. Without
coverage for the other providers, a future change to how one of them
collects its secretRefs could silently break the requeue path with
nothing in CI to catch it.

Add one case each for Akamai, AzureDNS, Cloudflare, AcmeDNS,
DigitalOcean and RFC2136, matching the existing Route53/CloudDNS case
style. Verified against internal/apis/certmanager/validation/issuer.go
to set the minimum fields each provider needs for its secretRef(s) to
be collected.

Signed-off-by: Richard Wall <[email protected]>
expectErr was declared in the test table and checked in the test loop,
but no case ever set it to true, so the "conversion failed" branch was
dead code that gave false confidence the error path was covered.

It isn't reachable in practice: RequiredDNS01SolverSecrets' only error
comes from api.Scheme.Convert converting the external
ACMEChallengeSolver to its internal type, and that conversion (see
internal/apis/acme/v1/zz_generated.conversion.go) is generated
field-by-field copying with no parsing or validation, so it cannot
fail for any value of the external Go struct type. Drop the unused
field and branch, and note why in a comment so a future reader doesn't
assume the gap is accidental.

Signed-off-by: Richard Wall <[email protected]>
@wallrj-cyberark

Copy link
Copy Markdown
Member

After a Claude-assisted self-review of the changes above, pushed a couple of follow-up fixes: 7991126→bdbde6983 makes the DNS-01 solver-secret lookup fail safe per-issuer instead of aborting the whole match on a conversion error, and bdbde69→3b6d4ead3 broadens RequiredDNS01SolverSecrets test coverage to the remaining DNS-01 providers. Current head: 3b6d4ea.

@wallrj-cyberark
wallrj-cyberark requested a review from Copilot July 22, 2026 15:54

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

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Comment thread pkg/acme/secrets.go Resolved
Comment thread pkg/controller/clusterissuers/checks.go Resolved
Comment on lines +54 to 68
// Match DNS-01 solver secrets so creating a missing solver Secret
// re-queues the Issuer (see #9036).
solverSecrets, err := acme.RequiredDNS01SolverSecrets(iss)
if err != nil {
// Don't let one issuer's conversion error stop every other
// issuer from being matched against this Secret event.
runtime.HandleError(fmt.Errorf("error determining ACME DNS-01 solver secrets for issuer %s/%s: %w", iss.Namespace, iss.Name, err))
continue
}
for _, s := range solverSecrets {
if s.Name == secret.Name {
affected = append(affected, iss)
continue
break
}
}

@wallrj-cyberark wallrj-cyberark Jul 22, 2026 •

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.

Fair point, and not something I'd dismiss outright, but I don't think it warrants blocking this fix.

Some context: issuersForSecret() already did an O(numIssuers) linear scan per Secret event before this PR (the CA/Venafi/Vault cases below all do per-issuer field comparisons too) - what changed is the per-ACME-issuer constant factor, from a handful of string comparisons to a Scheme.Convert (a map lookup to a generated field-copy function, not reflection-based marshaling) plus a validation walk over that issuer's own DNS-01 solvers. That's heavier, but bounded by the number of solvers on a single issuer, not cluster-wide Secret count.

Indexing Issuers by referenced Secret name (including solver secrets) would need to stay in sync as Issuers themselves are added/updated, which is a real design task in its own right, and this PR is aimed at a v1.21.1 patch release fixing a stuck-forever bug - I'd rather not couple that timeline to a cache-invalidation design. Happy to be overruled if a maintainer wants it done here rather than as a follow-up, since it's a legitimate scalability question for very large ACME-issuer counts with high Secret churn - leaving this open for code reviewer to weigh in.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I agree with richard here.. that we should fix the bug before handling the scalability issue but I would love to see a comment with a TODO.. maybe assigned to some maintainer me or @wallrj-cyberark so that we can come back and fix it later and not forget about it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@hjoshi123

I would love to see a TODO with the scalability comment so that we can address it in a different PR

Added in-tree // TODO(hjoshi123, wallrj): on issuersForSecret in both:

  • pkg/controller/issuers/checks.go
  • pkg/controller/clusterissuers/checks.go

It notes the O(numIssuers) Secret-event walk, the extra ACME DNS-01 conversion cost, and the follow-up (index by referenced Secret names). Commit c76589b06.

…crets

RequiredDNS01SolverSecrets is an exported function in pkg/acme, a
non-internal package, but returned []*internal/apis/meta.SecretKeySelector
- an internal/... type. Any consumer of this module outside
github.com/cert-manager/cert-manager cannot import that internal
package, so it could receive the return value but never name its
element type directly. Flagged by Copilot on re-review.

Convert each internal SecretKeySelector to the external
pkg/apis/meta/v1 type (identical Name/Key shape, existing generated
conversion function) before returning, so the public function only
ever exposes public types. No caller needed to change: every call site
only accesses the exported Name/Key fields, which behave the same
whether the slice holds pointers or values.

Signed-off-by: Richard Wall <[email protected]>
pkg/controller/clusterissuers/checks.go logged "for issuer %s" when
handling a solver-secret conversion error for a ClusterIssuer, unlike
the equivalent message in pkg/controller/issuers/checks.go which
correctly names its resource kind. Flagged by Copilot on re-review:
using the generic term here makes it harder to tell which controller
logged the error when diagnosing.

Signed-off-by: Richard Wall <[email protected]>
@hjoshi123

Copy link
Copy Markdown
Collaborator

Mostly looks good to be me @SebTardif @wallrj-cyberark. I would love to see a TODO with the scalability comment so that we can address it in a different PR

hjoshi123 asked for an in-tree TODO so the O(numIssuers) Secret-event scan
and per-ACME RequiredDNS01SolverSecrets cost are not forgotten after the

Signed-off-by: Sebastien Tardif <[email protected]>
cert-manager#9036 re-queue fix lands. Follow-up: index by referenced Secret names.
@SebTardif

Copy link
Copy Markdown
Contributor Author

@hjoshi123

I would love to see a TODO with the scalability comment so that we can address it in a different PR

Added in-tree // TODO(hjoshi123, wallrj): on issuersForSecret in both:

  • pkg/controller/issuers/checks.go
  • pkg/controller/clusterissuers/checks.go

It notes the O(numIssuers) Secret-event walk, the extra ACME DNS-01 conversion cost, and the follow-up (index by referenced Secret names). Commit c76589b06.

@hjoshi123

Copy link
Copy Markdown
Collaborator

Thank you @SebTardif for making the changes.. LGTM! @wallrj-cyberark if you can add the final approval as an indication that you approve too!

/lgtm

@cert-manager-prow cert-manager-prow Bot added the lgtm Indicates that a PR is ready to be merged. label Jul 29, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member

/approve

@wallrj

wallrj commented Jul 29, 2026

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 the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Jul 29, 2026
@cert-manager-prow
cert-manager-prow Bot merged commit 49f887b into cert-manager:master Jul 29, 2026
6 checks passed
@cert-manager-bot

Copy link
Copy Markdown
Contributor

@wallrj-cyberark: new pull request created: #9083

Details

In response to this:

/cherry-pick release-1.21

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.

@wallrj-cyberark

Copy link
Copy Markdown
Member

/cherry-pick release-1.21

@cert-manager-bot

Copy link
Copy Markdown
Contributor

@wallrj-cyberark: new pull request could not be created: failed to create pull request against cert-manager/cert-manager#release-1.21 from head cert-manager-bot:cherry-pick-9042-to-release-1.21: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for cert-manager-bot:cherry-pick-9042-to-release-1.21."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request","status":"422"}

Details

In response to this:

/cherry-pick release-1.21

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.

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/acme Indicates a PR directly modifies the ACME Issuer code 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. ok-to-test release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cert-manager 1.21: ACME solver Secret changes don't trigger Issuer/ClusterIssuer re-reconciliation (stuck at Ready:False/InvalidSolver)

6 participants