Skip to content

rotator: filter secret cache by name - #590

Open
Hrishikeshkashyap wants to merge 1 commit into
open-policy-agent:masterfrom
Hrishikeshkashyap:fix/filter-secret-cache-by-name
Open

Hrishikeshkashyap wants to merge 1 commit into
open-policy-agent:masterfrom
Hrishikeshkashyap:fix/filter-secret-cache-by-name

Conversation

@Hrishikeshkashyap

@Hrishikeshkashyap Hrishikeshkashyap commented Oct 19, 2026 •

Copy link
Copy Markdown

Description

cert-controller manages a specific Secret containing the webhook TLS certificate. However, the current Secret cache watches all Secrets in the namespace, even though the rotator already knows the exact Secret it needs through SecretKey.

This change filters the Secret cache using metadata.name, so it watches only the configured certificate Secret.

Why

This enables consumers to apply least-privilege RBAC and restrict Secret access using resourceNames, instead of requiring access to all Secrets in the namespace.

The filter applies only to Secrets, so the existing webhook configuration informers remain unaffected.

As a secondary benefit, filtering the Secret cache also avoids caching and processing unrelated Secrets, reducing unnecessary watch traffic and cache usage.

Changes

  • Filter the Secret cache using cr.SecretKey.Name.
  • Keep webhook configuration caching unchanged.

@codecov-commenter

codecov-commenter commented Oct 19, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 62.21%. Comparing base (190188d) to head (205f369).
⚠️ Report is 245 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #590      +/-   ##
==========================================
+ Coverage   57.16%   62.21%   +5.04%     
==========================================
  Files           1        1              
  Lines         572      487      -85     
==========================================
- Hits          327      303      -24     
+ Misses        181      118      -63     
- Partials       64       66       +2     
Flag Coverage Δ
unittests 62.21% <100.00%> (+5.04%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Hrishikeshkashyap
Hrishikeshkashyap force-pushed the fix/filter-secret-cache-by-name branch from 37d6bcc to 9939e36 Compare October 19, 2026 16:56
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Signed-off-by: Hrishikesh Kashyap <hrkashyap@microsoft.com>
@Hrishikeshkashyap
Hrishikeshkashyap force-pushed the fix/filter-secret-cache-by-name branch from 9939e36 to 205f369 Compare October 20, 2026 13:21
@Hrishikeshkashyap

Copy link
Copy Markdown
Author

@JaydipGabani Could you please take a look at this PR when you get a chance? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants