Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Enhancement] Use Streaming Lists when available #244

Merged
merged 5 commits into from
Sep 20, 2023

Conversation

KiptoonKipkurui
Copy link
Member

@KiptoonKipkurui KiptoonKipkurui commented Sep 14, 2023

Description
This PR Addresses an issue of potential runaway usage of memory due to chucking of reported statuses while watching for Kubernetes resources. Kubernetes 1.27 introduces a WatchList feature still at the alpha stage that allows one to get statuses of objects being watched as a streaming list as opposed to current implementations that uses a list request first before a watch request. This is done by setting sendInitialEvents=true param in a watch request.
This PR fixes #221

Notes for Reviewers
This is still WIP and is allow continuous conversation to allow seamless integration with existing infrastructure

Signed commits

  • [ x] Yes, I signed my commits.

Kubernetes version that has the WatchList version

Signed-off-by: Daniel Kiptoon <[email protected]>
Interface to receive updates from Kubernetes on the given API types and
publishes them to the broker

Signed-off-by: Daniel Kiptoon <[email protected]>
on configuration

Signed-off-by: Daniel Kiptoon <[email protected]>
underlying functions

Signed-off-by: Daniel Kiptoon <[email protected]>
func New(log logger.Handler, informer dynamicinformer.DynamicSharedInformerFactory, broker broker.Handler, plConfigs map[string]internalconfig.PipelineConfigs, stopChan chan struct{}) *pipeline.Pipeline {
func New(log logger.Handler, informer dynamicinformer.DynamicSharedInformerFactory, broker broker.Handler, plConfigs map[string]internalconfig.PipelineConfigs, stopChan chan struct{}, dynamicKube dynamic.Interface) *pipeline.Pipeline {
// TODO: best way to check whether WatchList feature is enabled
watchList := true
Copy link
Member Author

Choose a reason for hiding this comment

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

I have looked around for ways of determining the enabled features in a Kubernetes cluster, but most knowledge revolves around looking at actual cluster configuration to see what has been enabled and what hasn't been enabled...I would appreciate any pointers to how I can determine programmatically which features have been enabled or not

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

Thank you for this resources, I will check them out

// Launch the goroutine and pass the channel as an argument
wg.Add(1)
go w.backgroundWatchProcessor(watcher.ResultChan(), w.stopChan, &wg)
data := make(map[string]cache.Store)
Copy link
Member Author

Choose a reason for hiding this comment

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

This data which is essentially a cache used by the informer is used downstream. I would like to understand the potential downfall of not including it as none is accessible while using a watch

w.log.Info("Received ADD event for: ", obj.(*unstructured.Unstructured).GetName(), "/", obj.(*unstructured.Unstructured).GetNamespace(), " of kind: ", obj.(*unstructured.Unstructured).GroupVersionKind().Kind)
// when an event is modified...
case watch.Modified:
err := w.publishItem(obj.(*unstructured.Unstructured), broker.Update, w.config)
Copy link
Member Author

Choose a reason for hiding this comment

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

For the Update functionality, using informers, one could get the older object and the new object and hence we could compare resource versions to determine whether indeed this object is a valid update or a repeated action. This is not available when using watchers

@KiptoonKipkurui
Copy link
Member Author

Using streaming lists boils down to adding the flag sendInitialEvents=true param in a watch request without a List request for the desired Kubernetes object. DynamicInformers also use ListWatch functionality under the hood, and may eventually come to support use of streaming lists.

@KiptoonKipkurui
Copy link
Member Author

@leecalcote

@leecalcote
Copy link
Member

@KiptoonKipkurui, great presentation today, sir.

@leecalcote leecalcote requested review from theBeginner86 and removed request for Revolyssup and humblenginr September 20, 2023 16:10
@MUzairS15 MUzairS15 merged commit 3f46529 into meshery:master Sep 20, 2023
@KiptoonKipkurui
Copy link
Member Author

@MUzairS15 this isn't ready for a master merge, it will break functionality

@MUzairS15
Copy link

Thanks for informing, reverting and reopening you can work on that PR.

@KiptoonKipkurui
Copy link
Member Author

I breath again

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Enhancement] Use Streaming Lists when available
3 participants