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

✨ Populate/update cache on ClusterCatalog reconcile #1284

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

m1kola
Copy link
Member

@m1kola m1kola commented Sep 19, 2024

Description

Currently we fetch catalog data and populate cache on demand during ClusterExtension reconciliation. This works but the first reconciliation after ClusterCatalog creation or update is slow due to the need to fetch data.

With this change we proactively populate cache on ClusterCatalog creation and check if cache needs to be updated on ClusterCatalog update.

Reviewer Checklist

  • API Go Documentation
  • Tests: Unit Tests (and E2E Tests, if appropriate)
  • Comprehensive Commit Messages
  • Links to related GitHub Issue(s)

@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 19, 2024
Copy link

netlify bot commented Sep 19, 2024

Deploy Preview for olmv1 ready!

Name Link
🔨 Latest commit 482531d
🔍 Latest deploy log https://app.netlify.com/sites/olmv1/deploys/6707dc46ab49880008b6a385
😎 Deploy Preview https://deploy-preview-1284--olmv1.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

codecov bot commented Sep 19, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.96%. Comparing base (d262e32) to head (482531d).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1284      +/-   ##
==========================================
+ Coverage   74.67%   74.96%   +0.28%     
==========================================
  Files          42       42              
  Lines        2515     2516       +1     
==========================================
+ Hits         1878     1886       +8     
+ Misses        451      446       -5     
+ Partials      186      184       -2     
Flag Coverage Δ
e2e 56.55% <65.00%> (-0.03%) ⬇️
unit 53.10% <80.00%> (+0.41%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Comment on lines 53 to 59
_, err = r.Cache.FetchCatalogContents(ctx, existingCatalog)
return ctrl.Result{}, err
Copy link
Member

Choose a reason for hiding this comment

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

One benefit of the previous approach is that catalog pull errors will show up in ClusterExtension status.

If we move catalog cache populate to a separate controller, do users lose all visibility into the specific details of the reason the catalog caches aren't populated?

I wonder if we should store these errors somewhere that is available to the ClusterExtension reconciler so that we can still propagate them into ClusterExtension status?

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'm considering keeping on-demand cache population. If cache fetch fails here - we will keep re-queueing until it gets populated. If it doesn't and it is something permanent - cache population will fail during ClusterExtension itself and it will be propagated to ClusterExtension status as it currently works.

It should work, but I don't like it very much because it is not straightforward to understand.

I wonder if we should store these errors somewhere that is available to the ClusterExtension reconciler so that we can still propagate them into ClusterExtension status?

Any ideas? We can probably store somewhere in filesystemCache (e.g. in cacheDataByCatalogName)?

Copy link
Member

Choose a reason for hiding this comment

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

High level idea would be for the interface that ClusterExtension uses to remain the same (e.g. it can return an error).

Yeah cacheDataByCatalogName seems like the obvious place. We could have cacheData include an Err field?

Copy link
Member Author

@m1kola m1kola Sep 29, 2024

Choose a reason for hiding this comment

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

@joelanford could you please take a look at #1318?

I refactored the client and cache: the client is now responsible for http requests and cache is responsible for caching only (previously it was making request). And I also added error propagation.

The idea is that here instead of r.Cache.FetchCatalogContents we will be calling client's PopulateCache.

Once it is merged I'll be able to rebase this PR on top of the changes.

@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 22, 2024
@m1kola m1kola force-pushed the populate-cache-on-from-controller branch from 28b3312 to 72e1586 Compare September 23, 2024 14:43
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 23, 2024
@m1kola m1kola force-pushed the populate-cache-on-from-controller branch from 72e1586 to 4b76985 Compare September 23, 2024 14:45
@m1kola m1kola force-pushed the populate-cache-on-from-controller branch 4 times, most recently from 71c2382 to 80763b1 Compare October 10, 2024 13:47
Currently we fetch catalog data and populate
cache on demand during ClusterExtension reconciliation.
This works but the first reconciliation after ClusterCatalog
creation or update is slow due to the need to fetch data.

With this change we proactively populate cache on ClusterCatalog
creation and check if cache needs to be updated
on ClusterCatalog update.

Signed-off-by: Mikalai Radchuk <[email protected]>
@m1kola m1kola force-pushed the populate-cache-on-from-controller branch from 80763b1 to 482531d Compare October 10, 2024 13:53
@m1kola m1kola marked this pull request as ready for review October 10, 2024 14:01
@m1kola m1kola requested a review from a team as a code owner October 10, 2024 14:01
@openshift-ci openshift-ci bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Oct 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants