Skip to content

feat: project identity embedded in storage key#647

Open
savme wants to merge 1 commit into
mainfrom
feat/key-embedded-project-ident
Open

feat: project identity embedded in storage key#647
savme wants to merge 1 commit into
mainfrom
feat/key-embedded-project-ident

Conversation

@savme

@savme savme commented Jun 5, 2026

Copy link
Copy Markdown

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 from request.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):

metric value per project
heap 3.0 MiB / project
sys 5.0 MiB / project
goroutines 56 / project
etcd watchers 0 / project

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.

@savme savme marked this pull request as ready for review June 8, 2026 13:14
@savme savme requested a review from scotwells June 9, 2026 10:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant