fix(performance): scope Deployment/StatefulSet cache to operator-managed objects [RHDHBUGS-3569] - #3333
Conversation
…naged objects The metadata informers for Deployments and StatefulSets cached PartialObjectMetadata for every object of those kinds cluster-wide, causing OOM on large multi-tenant clusters (~800 MB heap with 2000 users). Add unconditional cache.ByObject label selectors for Deployments and StatefulSets filtered on app.kubernetes.io/name=backstage, so only operator-managed objects are cached. Replace WatchesMetadata with Owns() for idiomatic ownerReference-based event mapping. Assisted-by: Claude <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-1.10 #3333 +/- ##
================================================
+ Coverage 61.05% 61.57% +0.52%
================================================
Files 37 37
Lines 2108 2090 -18
================================================
Hits 1287 1287
+ Misses 686 668 -18
Partials 135 135
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
… watch events Add predicate-based V(1) logging to the Owns() watchers for Deployments and StatefulSets, preserving the "enqueuing reconcile on change of" debug messages that were previously emitted by requestByAppLabels. Each log entry now also includes the event type (create, update, delete). Assisted-by: Claude <noreply@anthropic.com>
02399cd to
c08f089
Compare
|
|
/agentic_review |
|
/cherrypick main |
|
@rm3l: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
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. |
Code Review by Qodo
1. Cache selector too broad
|
|
/build-images |
|
✅ PR images built successfully! Images are available for testing:
Also available with PR number tag:
Triggered by @rm3l |
PR Summary by QodoScope Deployment/StatefulSet cache to operator-managed objects to prevent OOM
AI Description
Diagram
High-Level Assessment
Files changed (2)
|
|
Code review by qodo was updated up to the latest commit c08f089 |



Description
The metadata informers for Deployments and StatefulSets cache
PartialObjectMetadatafor every object of those kinds cluster-wide, regardless of whether they are managed by the operator. Predicates only control whether a reconcile is enqueued — they do not reduce cache size.On large multi-tenant clusters (e.g. Dev Sandbox with 2000 users), this causes the operator to OOM-crash: heap grows from ~17 MB to ~800 MB, with 63% consumed by
ObjectMeta.Unmarshalin the metadata informer LIST path. This happens even withENABLE_CACHE_LABEL_FILTER=trueandTransformStripManagedFieldsactive, since those only cover Secrets/ConfigMaps.This PR:
cache.ByObjectlabel selectors for Deployments and StatefulSets filtered onapp.kubernetes.io/name=backstage, so only operator-managed objects are cached. This is server-side filtering and is not a breaking change: unlike Secrets/ConfigMaps, users do not create Deployments/StatefulSets for the operator; it creates them itself and always sets this label.WatchesMetadatawithOwns()for idiomatic ownerReference-based event mapping. The operator already setscontrollerutil.SetControllerReferenceon all Deployments/StatefulSets it creates.Which issue(s) does this PR fix or relate to
PR acceptance criteria
How to test changes / Special notes to the reviewer
Perf team should verify memory usage with the 2000-user Dev Sandbox test. Expected result: operator memory drops from ~800 MB to tens of MB.