feat: project identity embedded in storage key#647
Open
savme wants to merge 1 commit into
Open
Conversation
6 tasks
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.
Related #596
Alternative implementation in #635.
Project storage today scales linearly with project count: one full cacher/watch stack per project per resource. At realistic project counts this dominates apiserver memory and connection budget. The goal of this branch is to find out how far we can get with the upstream apiserver storage stack without patching it.
Approach
One cacher per resource for the whole apiserver. Tenant isolation is enforced by disjoint key subtrees in storage and by aligning the cacher's in-memory btree with those subtrees.
storage.Interface: rewrites every incoming key to inject a scope segment derived fromrequest.ProjectID(ctx)value.Transformer+runtime.Codec: the transformer prepends the storage key to the bytes flowing out of storage; the codec splits it back off and hands the key to the per-cacher side channel. Nothing tenant-related is written onto the object itself — no annotations, no labels, no client-visible identity.tenantMap: per-cacher tenant information. Bounded by the cacher's live objects.Numbers
Scale benchmark; 100 projects across 5 runs (using the harness from #615):
What didn't make it
Annotation/label-based tenant tracking: either leaks tenant identity to API clients or requires careful cleanup at multiple points. Side-channel keeps it inside storage.