Skip to content

Fix #8994 (approach A): widen return type to metav1.Object - #9004

Merged
cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
wallrj-cyberark:8994-fix-a-return-metav1-object
Jul 17, 2026
Merged

cert-manager-prow[bot] merged 1 commit into
cert-manager:masterfrom
wallrj-cyberark:8994-fix-a-return-metav1-object

Conversation

@wallrj-cyberark

@wallrj-cyberark wallrj-cyberark commented Jul 10, 2026 •

Copy link
Copy Markdown
Member

Summary

Minimal fix for #8994 — change the return type of
EnqueueCertificatesForResourceUsingPredicates from func(U) to
func(metav1.Object) and add an internal type assertion.

  • The metadata informer delivers *v1.PartialObjectMetadata to handlers
    that were previously typed as func(*corev1.Secret), causing failed
    type assertions and log spam.
  • With this change the returned function accepts metav1.Object, then
    internally asserts to U (e.g. *corev1.Secret) — silently skipping
    objects that do not match. This is safe because only the typed informer
    delivers labelled Secrets; metadata events for non-labelled Secrets are
    correctly ignored by the certificate sub-controllers.

This is the smallest possible fix and suitable for backport to
release-1.21.

See also:

All three PRs target master for review and CI; they are mutually
exclusive approaches to the same issue.

Motivation

#8994 — discovered shortly after the 1.21.0
release. The generics refactor in #8407 changed the handler signature
from func(interface{}) to func(U), which broke the dual-informer
Secret handler path.

Test plan

  • go test ./pkg/controller/certificates/... — all pass
  • go test ./pkg/controller/ — TestBlockingEventHandler,
    TestFilterEventHandler pass
  • No new tests needed; this is a type-signature change with an internal
    guard

Testing evidence: log spam confirmed fixed in CI

Compared the controller log from this PR's own e2e run against the exact
log linked in #8994's original report:

Baseline (pre-fix, log linked in #8994) This PR's e2e run
Log source release-1.21 periodic job pull-cert-manager-master-e2e-v1-36 (job succeeded)
Total log lines 4,530 13,131
OnAdd/OnUpdate/OnDelete missing-object errors 2,065 0

Sanity-checked this isn't a false negative from an idle run: the metadata
informer for Secrets is confirmed active in this PR's run
("Caches populated" type="*v1.PartialObjectMetadata" at startup), and
there's substantial Secret-related activity throughout (certificate
re-issuance, secret lookups, ~1,285 secret-related log lines) — so the
code path that previously spammed was live and exercised, and is silent
under this fix.

Note on the total line-count difference (4,530 vs. 13,131): this is
explained by run duration, not test scope. The baseline log spans
6m05s (11:34:20–11:40:25) vs. 14m33s (12:36:29–12:51:02) for this PR's
run — a 2.4x longer run. Per-second log rates are comparable (12.4
lines/s baseline vs. 15.0 lines/s here), so the extra lines are simply
from running longer, not from a lighter/different test suite. If
anything this strengthens the result: the baseline log's last 10 lines
are still mid-spam (OnUpdate missing ObjectOld, OnDelete missing Object), suggesting that artifact is a truncated snapshot of a longer
run rather than a graceful end-of-job log — so the true baseline spam
count over a comparable window would likely be higher, not lower. This
PR's run logged at an equal-or-higher rate over more wall-clock time
and produced zero occurrences of the error.

Release Note

Fix log spam and dropped Secret informer events for non-cert-manager Secrets, caused by a generics regression introduced in 1.21.0.

Change the return type of EnqueueCertificatesForResourceUsingPredicates
from func(U) to func(metav1.Object), adding an internal type assertion
that silently skips objects that do not match the concrete type U.

This is the minimal fix for the log spam described in cert-manager#8994, caused by
the metadata informer delivering *v1.PartialObjectMetadata to a handler
typed as func(*corev1.Secret). The return type change makes the handler
accept both concrete types from the filtered Secret informer.

Fixes: cert-manager#8994

Signed-off-by: Richard Wall <[email protected]>
Co-Authored-By: Claude <[email protected]>
Signed-off-by: Richard Wall <[email protected]>
@cert-manager-prow cert-manager-prow Bot added dco-signoff: yes Indicates that all commits in the pull request have the valid DCO sign-off message. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. needs-kind Indicates a PR lacks a `kind/foo` label and requires one. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Jul 10, 2026

@erikgb erikgb 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.

/lgtm
/approve
/hold

This looks like the simplest quickfix to me. Adding a hold to allow others to chime in.

@cert-manager-prow cert-manager-prow Bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. labels Jul 10, 2026
@cert-manager-prow

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: erikgb

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 10, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member Author

Updated the description above with the release note and CI log evidence confirming the log spam is gone (0 occurrences in this PR's e2e run vs. 2,065 in the baseline log linked from #8994). Adding this as a comment too since Prow doesn't re-scan the description for label triggers after the fact.

/kind bug

@cert-manager-prow cert-manager-prow Bot added kind/bug Categorizes issue or PR as related to a bug. release-note Denotes a PR that will be considered when it comes time to generate release notes. and removed needs-kind Indicates a PR lacks a `kind/foo` label and requires one. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Jul 17, 2026
@wallrj-cyberark

Copy link
Copy Markdown
Member Author

/hold cancel
/cherry-pick release-1.21

@cert-manager-prow cert-manager-prow Bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 17, 2026
@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:

/hold cancel
/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.

@cert-manager-prow
cert-manager-prow Bot merged commit ce541d2 into cert-manager:master Jul 17, 2026
5 checks passed
@cert-manager-bot

Copy link
Copy Markdown
Contributor

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

Details

In response to this:

/hold cancel
/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. 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/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants