Skip to content

Conversation

lentzi90
Copy link
Contributor

What this PR does / why we need it:

This allows filtering the Clusters that are handled by the cache. It can be used for example by providers that only want to cache Clusters of the relevant type to them.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #12657

/area clustercache

@k8s-ci-robot k8s-ci-robot added area/clustercache Issues or PRs related to the clustercachetracker cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Aug 22, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign fabriziopandini for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found 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

@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Aug 22, 2025
@sivchari
Copy link
Member

Please write the test about this.

// ClusterFilter is a function that can be used to filter which clusters should be handled
// by the ClusterCache. If nil, all clusters will be handled. If set, only clusters for which
// the filter returns true will be handled.
ClusterFilter ClusterFilter
Copy link
Member

@sbueringer sbueringer Aug 22, 2025

Choose a reason for hiding this comment

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

Let's add some simple unit test coverage (for the reconciler logic)

This allows filtering the Clusters that are handled by the cache.
It can be used for example by providers that only want to cache Clusters
of the relevant type to them.

Signed-off-by: Lennart Jern <lennart.jern@est.tech>
@lentzi90 lentzi90 force-pushed the lentzi90/cluster-cache-filter branch from 2e015ff to 165bddb Compare August 22, 2025 12:50
@lentzi90
Copy link
Contributor Author

Now maybe the code looks better?
(I'll get to the tests also, but it will probably be next week)

@sbueringer
Copy link
Member

sbueringer commented Aug 25, 2025

Now maybe the code looks better? (I'll get to the tests also, but it will probably be next week)

Yup!

I'm wondering if we need test coverage for cases where the filter returns different results for the same cluster over time, as that seems to be supported now?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/clustercache Issues or PRs related to the clustercachetracker cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ClusterCache behavior is not fully documented in GoDoc
4 participants