Skip to content

✨ Add ClusterFilter to ClusterCache Options#12665

Merged
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
Nordix:lentzi90/cluster-cache-filter
Mar 7, 2026
Merged

✨ Add ClusterFilter to ClusterCache Options#12665
k8s-ci-robot merged 1 commit intokubernetes-sigs:mainfrom
Nordix:lentzi90/cluster-cache-filter

Conversation

@lentzi90
Copy link
Copy Markdown
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 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
Copy Markdown
Member

Please write the test about this.

Comment thread controllers/clustercache/cluster_cache.go Outdated
Comment thread controllers/clustercache/cluster_cache.go
@lentzi90 lentzi90 force-pushed the lentzi90/cluster-cache-filter branch from 2e015ff to 165bddb Compare August 22, 2025 12:50
@lentzi90
Copy link
Copy Markdown
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
Copy Markdown
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?

@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 10, 2025
@lentzi90
Copy link
Copy Markdown
Contributor Author

My naive attempt to test this did not go so well 😓
I guess it is now failing because after I change the label, the cluster is still cached. So I would need to manipulate the time or something to get to a point when the cluster is no longer there.
I'm not sure that is the way to go. Any suggestions?

@sbueringer
Copy link
Copy Markdown
Member

My naive attempt to test this did not go so well 😓 I guess it is now failing because after I change the label, the cluster is still cached. So I would need to manipulate the time or something to get to a point when the cluster is no longer there. I'm not sure that is the way to go. Any suggestions?

The problem is simply that you are trying to patch labels with the status subresource :)

g.Expect(env.Status().Patch(ctx, testCluster, patch)).To(Succeed())

(in l.129 + l.143)

@lentzi90
Copy link
Copy Markdown
Contributor Author

Oh my 🤦
Thank you!

@lentzi90 lentzi90 force-pushed the lentzi90/cluster-cache-filter branch from 5ac3629 to ed97655 Compare September 12, 2025 05:58
@sbueringer
Copy link
Copy Markdown
Member

I'll try to take a closer look next week

Comment thread controllers/clustercache/cluster_cache.go
@sbueringer
Copy link
Copy Markdown
Member

@lentzi90 Do you have time to address the finding above?

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 ed97655 to 94233c1 Compare October 21, 2025 07:25
@lentzi90
Copy link
Copy Markdown
Contributor Author

I forgot about it, but now I think I have addressed it. Looks good according to the tests at least. 🙂

@sbueringer
Copy link
Copy Markdown
Member

I'll have to get back to this after PTO :)

@k8s-triage-robot
Copy link
Copy Markdown

The Kubernetes project currently lacks enough contributors to adequately respond to all PRs.

This bot triages PRs according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the PR is closed

You can:

  • Mark this PR as fresh with /remove-lifecycle stale
  • Close this PR with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 24, 2026
@sbueringer
Copy link
Copy Markdown
Member

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Feb 24, 2026
@sbueringer
Copy link
Copy Markdown
Member

Thank you very much!

/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 7, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

LGTM label has been added.

DetailsGit tree hash: 163b8ba54172781fe84d861176017b9a17856045

@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: sbueringer

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

The pull request process is described here

Details 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 approved Indicates a PR has been approved by an approver from all required OWNERS files. label Mar 7, 2026
@k8s-ci-robot k8s-ci-robot merged commit 63e227b into kubernetes-sigs:main Mar 7, 2026
19 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.13 milestone Mar 7, 2026
@lentzi90 lentzi90 deleted the lentzi90/cluster-cache-filter branch March 9, 2026 06:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/clustercache Issues or PRs related to the clustercachetracker cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 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

6 participants