Repository navigation
perf: Skip the per-cluster access check when the user can get all clusters - #199
Merged
gianlucam76 merged 1 commit intoOct 27, 2026
Conversation
…sters GET /profile made one SubjectAccessReview per matching cluster. Ask once per cluster type whether the user can get all clusters of that type, and skip the per-cluster checks if so. Other users are checked cluster by cluster, as before. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
GET /profile lists the clusters a profile matches and drops the ones the user
is not allowed to see. It did this with one SubjectAccessReview per matching
cluster, each one a call to the API server, each one with a new clientset. A
profile matching 1,000 clusters meant 1,000 calls, even for a user who can
see every cluster.
This asks once, per cluster type, whether the user can get all SveltosClusters
(or all CAPI Clusters) in all namespaces. If so, every cluster of that type is
allowed without further calls. Otherwise the existing per-cluster check runs,
as before.
The shortcut uses the get verb, not list, so the answer cannot change for
any user: cluster-wide get on the resource implies get on each cluster. A user
whose get is limited to some namespaces or to named clusters is denied the
cluster-wide check and falls back to the per-cluster path. For those users the
result is the same as before, and the cost is one extra call per cluster type.
canGetCluster and the other check helpers are unchanged.
Measured on envtest, calling getProfileSpecAndMatchingClusters with real
SubjectAccessReviews, on main and on this branch (3 to 10 iterations on one
machine, indicative only):
User who can get all clusters, 1,000 matching clusters:
clientset built for each check.
latency (simulated, not measured on a real API server): 7.4 s before, 9 ms
after.
User who can get only some clusters (a rule naming one cluster):
So there is no gain for these users, and the cost is the same within noise.
Tests:
SubjectAccessReview requests that reach it: 1 for 20 clusters for a user
who can get all SveltosClusters, 2 for a mix of SveltosClusters and CAPI
Clusters, and 1 plus one per cluster for a user limited to a named cluster,
who is allowed only that cluster. A user with no permission is denied every
cluster.
of 1, 12 instead of 2).
image. It uses an admin token, so it goes through the shortcut.
🤖 Generated with Claude Code