Skip to content

perf(operator): stop caching the content of every Secret in the cluster - #327

Merged
BryanFRD merged 2 commits into
mainfrom
fix/314-metadata-only-secret-cache
Oct 25, 2026
Merged

BryanFRD merged 2 commits into
mainfrom
fix/314-metadata-only-secret-cache

Conversation

@BryanFRD

Copy link
Copy Markdown
Contributor

Secret watches (Owns and Watches in both controllers) are now metadata-only, and Secret reads go straight to the API server instead of the cache. The operator no longer holds the data of every Secret in the cluster in memory.

The label-filtered cache from the issue is not used: target Secrets can pre-exist without the label, so a filtered cache would make create-or-update fail with AlreadyExists. Cost is one API read per Secret per reconcile.

Closes #314

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Looks correct. Both Secret map funcs (secretsReferencingTokenSecret and the inline one in the connection controller) only use GetName/GetNamespace, so OnlyMetadata is safe there. All typed Secret reads (TokenBroker.loadFromSecret, targetExists, targetContentHash, ensureTargetSecret) go straight to the API server because of DisableFor. Owned-Secret updates still fire, since resourceVersion is part of the metadata.

Nit: the package doc in internal/controller/token_broker.go:6-8 still says the tokenSecretRef path relies on "what the client cache already does on the Secret". That stops being true with this change: every reconcile now does a live GET. Worth rewording so nobody puts a cache back in to "restore" that behaviour.

Comment thread cmd/main_test.go
@BryanFRD
BryanFRD enabled auto-merge (squash) October 25, 2026 09:49

@ferrfleet-interne ferrfleet-interne Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

f33a4ef fixes the import grouping nit in cmd/main_test.go. Nothing else changed, still good.

@BryanFRD
BryanFRD merged commit fc465d7 into main Oct 25, 2026
19 checks passed
@BryanFRD
BryanFRD deleted the fix/314-metadata-only-secret-cache branch October 25, 2026 09:52
ferrflow Bot added a commit that referenced this pull request Oct 25, 2026
## [6.1.1] - 2026-10-25

### Bug Fixes

- perf(operator): stop caching the content of every Secret in the cluster (#327)
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.

perf(operator): stop caching every Secret in the cluster

1 participant