made getSubscriptions into an iterator to reduce memory usage #2383
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.
closes: https://issues.redhat.com/browse/RHOAIENG-2040
Description
The backend uses an old method of watching certain get requests and subscriptions were a part of that logic. The watcher code will pull the data on creation of the watcher so no matter what we were fetching up to 250 items. This can causes memory issues as these subscriptions can get big.
In this solution, we remove subscriptions form the watcher and instead implement a iterator. Now we pull 100 items at a time, don't store them in memory when fetch the next batch. And always exiting early on finding what we need
How Has This Been Tested?
Make a log statement in fetch subs function and check that it is pulling everything. Reach out to @Gkrumbach07 as he set up a cluster with 300+ operators subscriptions to test this better.
Test Impact
backend code n/a
Request review criteria:
Self checklist (all need to be checked):
If you have UI changes:
After the PR is posted & before it merges:
main