Add pkg/shardlookup#4063
Conversation
There was a problem hiding this comment.
Pull request overview
This PR extracts the shard-local vs remote-shard lookup and request coalescing logic (previously embedded in the serviceaccount token getter cache) into a new reusable pkg/shardlookup package, and updates the serviceaccount cache to use the new primitives.
Changes:
- Added
pkg/shardlookup.TTLCache(TTL + singleflight request coalescing) andpkg/shardlookup.Lookup(local-or-fetch wrapper). - Migrated
pkg/server/serviceaccount/cache.goto use the newshardlookupabstractions. - Removed the serviceaccount-specific
coalescing_cache.goimplementation.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pkg/shardlookup/ttl_cache.go | Introduces a generic TTL + singleflight cache used for cross-shard lookups. |
| pkg/shardlookup/lookup.go | Adds a reusable “local lister vs remote fetch” lookup wrapper keyed by cluster-aware keys. |
| pkg/shardlookup/doc.go | Provides package-level guidance on when to use shardlookup vs the cache server. |
| pkg/server/serviceaccount/cache.go | Switches SA/secret lookup to the new shardlookup cache + lookup wrappers. |
| pkg/server/serviceaccount/coalescing_cache.go | Deletes the previous serviceaccount-specific coalescing cache implementation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mjudeikis
left a comment
There was a problem hiding this comment.
/lgtm
/approve
Im not sure about naming of the packages but we can change this later. Or never :D
|
LGTM label has been added. DetailsGit tree hash: bfd0cd9aa6895135c412ce254f7c5b58d21587bc |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: mjudeikis The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
You and me both :D |
|
/cherry-pick 0.31 |
|
@ntnn: once the present PR merges, I will cherry-pick it on top of DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
@ntnn: cannot checkout DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/cherry-pick release-0.31 |
|
@ntnn: new pull request created: #4065 DetailsIn response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
Summary
Refactors the cache implemented for cross-shard SA lookup into pkg/shardlookup to be reused.
Related: #4061
What Type of PR Is This?
/kind cleanup
Related Issue(s)
Fixes #
Release Notes