Repository navigation
Conversation
… before caching Add the WithObjectTransform option. The function is applied to every Kubernetes object before the shared informers cache it and the hooks filter it, so an embedding application can drop fields no hook reads, such as metadata.managedFields, and cut the informer cache size. The transform is set on every shared informer and also applied to the initial list in loadExistedObjects, so the first snapshot checksums match the later watch events. Without the option objects are kept as is. Signed-off-by: Yuriy Losev <yuriy.losev@flant.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Overview
Add the
WithObjectTransformoption. It lets an application that embeds shell-operator transform every Kubernetes object before the shared informers cache it and the hooks filter it.What this PR does / why we need it
Informers cache full objects, including fields that no hook reads. On large clusters these fields take most of the operator memory. A heap profile of deckhouse-controller with the
DeckhouseHighMemoryUsagealert firing showed 2.8 GB of 3.2 GB of heap held by informer caches, about half of it inmetadata.managedFields. Node objects also carrystatus.images: every node update makes each Go hook filter convert the whole image list.Which fields are safe to drop depends on the hooks, so shell-operator keeps objects as is by default. An embedding application opts in with a function:
The same option works with
NewBareShellOperator: it is applied whenSetupEventManagerscreates the kube events manager.What changes:
FactoryStore.WithTransformstores the function, and every new shared informer gets it throughSetTransform. It covers the cache and the watch events.loadExistedObjectsapplies the same function to the initial list. Without it, the first snapshot checksums would differ from the later watch events, and hooks would get one spurious event per object.kubeEventsManager.WithObjectTransformpasses the function to the store. TheKubeEventsManagerinterface is unchanged.Special notes for your reviewer
*unstructured.Unstructuredfor unstructured input. Otherwise the initial list fails with an error naming the returned type.TestFactoryStore_TransformsObjectscovers both paths. It fails when either the informer transform or the initial list transform is disabled.addon-operatoroption that passes the function through, then deckhouse uses it to dropmanagedFieldsand nodestatus.images.