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

made getSubscriptions into an iterator to reduce memory usage #2383

Merged

Conversation

Gkrumbach07
Copy link
Member

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):

  • The developer has manually tested the changes and verified that the changes work
  • Commits have been squashed into descriptive, self-contained units of work (e.g. 'WIP' and 'Implements feedback' style messages have been removed)
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has added tests or explained why testing cannot be added (unit tests & storybook for related changes)

If you have UI changes:

  • Included any necessary screenshots or gifs if it was a UI change.
  • Included tags to the UX team if it was a UI/UX change (find relevant UX in the SMEs section).

After the PR is posted & before it merges:

  • The developer has tested their solution on a cluster by using the image produced by the PR to main

@Gkrumbach07
Copy link
Member Author

/hold

@openshift-ci openshift-ci bot added the do-not-merge/hold This PR is hold for some reason label Jan 23, 2024
@Gkrumbach07 Gkrumbach07 added do-not-merge/work-in-progress This PR is in WIP state and removed do-not-merge/hold This PR is hold for some reason do-not-merge/work-in-progress This PR is in WIP state labels Jan 23, 2024
@Gkrumbach07
Copy link
Member Author

tested on a cluster and prevents error from occurring. I am not sure if we need to make the number of requests lower. Right now it queries 100 at a time

@Gkrumbach07 Gkrumbach07 force-pushed the subscriptions-iterator branch 4 times, most recently from d902143 to b3e721a Compare January 23, 2024 21:12
Copy link
Member

@andrewballantyne andrewballantyne left a comment

Choose a reason for hiding this comment

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

We tested this on Gage's cluster that had the reproduced env of 300+ subs -- this pod did not crash (we did see it crash on main).

Copy link
Contributor

openshift-ci bot commented Jan 23, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: andrewballantyne

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-bot openshift-merge-bot bot merged commit 0f4d371 into opendatahub-io:main Jan 23, 2024
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants