NO-JIRA: Add WithOptions constructor and StripManagedFieldsTransform for KubeInformersForNamespaces - #2379
NO-JIRA: Add WithOptions constructor and StripManagedFieldsTransform for KubeInformersForNamespaces#2379sanchezl wants to merge 2 commits into
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: sanchezl The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
WalkthroughAdds configurable Kubernetes informer factories for multiple namespaces and a cache transform that removes managed fields. Unit tests cover namespace registration, cluster-wide behavior, managed-field removal, absent fields, and non-object inputs. ChangesInformer helper extensions
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 14 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (14 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
229fbe9 to
4b89708
Compare
Add a constructor that accepts SharedInformerOption arguments and forwards them to each per-namespace factory. This allows callers to use WithTransform and other informer options uniformly across all namespaces. Rewrite NewKubeInformersForNamespaces and NewKubeInformersForNamespacesWithResyncPeriod as thin wrappers around the new constructor to consolidate factory-creation logic.
Add a cache.TransformFunc that removes ManagedFields from objects before they are stored in the informer cache. ManagedFields can be 50-80% of serialized object size for server-side apply managed resources. This follows the same pattern used by upstream Kubernetes internally but is not exported there. Usable with the WithOptions constructor via informers.WithTransform(StripManagedFieldsTransform).
4b89708 to
bcd6d2d
Compare
|
@sanchezl: This pull request explicitly references no jira issue. 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 openshift-eng/jira-lifecycle-plugin repository. |
|
@sanchezl: all tests passed! Full PR test history. Your PR dashboard. DetailsInstructions 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. I understand the commands that are listed here. |
Summary
NewKubeInformersForNamespacesWithOptions, a constructor that acceptsSharedInformerOptionarguments and forwards them to each per-namespace factory. This allows callers to useWithTransformand other informer options uniformly across all namespaces.StripManagedFieldsTransform, acache.TransformFuncthat removesManagedFieldsfrom objects before they are stored in the informer cache. ManagedFields can be 50-80% of serialized object size for server-side apply managed resources. Inspired by the pattern in the lister wrappers ininformers.goand the inline transform used by upstream Kubernetes inpkg/controlplane/apiserver/config.go, which is not exported.Test plan
go test ./pkg/operator/v1helpers/...passesmake verifypassesSummary by CodeRabbit