fix(k8s): trim owner labels, bound owner cache, refresh discovery - #4812
Merged
Conversation
- Drop duplicated legacy k8s.owner.* indexed labels; only @k8s.owner.* synthetic labels plus top-level owner.kind/name/key are emitted now, halving per-container label payload. - Add TTL (5m) and a hard size cap to the owner lookup cache so it can't grow unbounded under ReplicaSet churn and so Forbidden/NotFound negatives recover after RBAC is granted without a restart. - Reset the discovery REST mapper once and retry on mapping failure so CRDs registered after startup resolve. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
Address review feedback on the owner-chain cleanup: - Throttle restMapper.Reset() to at most once per minute so a permanently unmappable owner kind (typo, uninstalled CRD) can't hammer the API server's discovery endpoint on every pod event. - pruneOwnerCache now evicts an arbitrary subset down to 3/4 capacity instead of clearing wholesale, avoiding refetch-all thrash when a cluster has more than ownerCacheMaxSize live owners within the TTL. - Add tests for TTL expiry refetch, graceful cache eviction, and the throttled discovery reset. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Addressed in 0c3766b:
On caching negative mapping results: skipped it on purpose so a CRD installed after startup still gets picked up within a minute rather than being stuck for the full TTL. The throttle keeps the cost bounded either way. Fixed the "reset once" comment wording too. |
|
Reviewed the diff. Overall solid cleanup, one design nit:
Everything else checks out:
|
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Owner
Author
|
Addressed in 5f6ec34:
Existing eviction test still covers it (inserts maxSize+100, asserts trim down to evictTo). |
|
Reviewed the k8s owner-chain cleanup (label dedup, cache TTL/cap, mapper reset throttle).
|
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.
Follow-up cleanup on the owner-chain grouping from #4811.
Changes
k8s.owner.*indexed labels. Only@k8s.owner.*synthetic labels plus top-levelowner.kind/name/keyare emitted now, halving the per-container label payload that ships over SSE/gRPC. The frontend already reads the synthetic set first, so the legacy indexed fallback was dead weight.Notes
Owner lookups in the
ContainerEventswatch loop are still synchronous, but the cache keys on owner UID so shared controllers (ReplicaSet/Deployment) resolve once per rollout. Leaving that on the hot path since moving it off would risk event reordering for little gain.Tests updated and passing (
go test -race ./internal/k8s, frontendk8s.spec.ts, typecheck).🤖 Generated with Claude Code