feat(registry): stop advertising watch and mutations on computed resources#331
Open
matthyx wants to merge 2 commits into
Open
feat(registry): stop advertising watch and mutations on computed resources#331matthyx wants to merge 2 commits into
matthyx wants to merge 2 commits into
Conversation
…urces ConfigurationScanSummary, VulnerabilitySummary, and GeneratedNetworkPolicy are generated on the fly and never stored: watching them can never deliver events, and mutations are always rejected by the storage layer. Yet discovery advertised the full verb set, so clients that trust discovery (e.g. Rancher steve, which sets up informers for every list+watch-able GVK) opened watches that silently never produced anything. Introduce ReadOnlyREST, a wrapper that delegates to genericregistry.Store without embedding it, deliberately implementing only rest.Getter, rest.Lister, rest.Scoper, rest.Storage and rest.SingularNameProvider. The endpoints installer decides verbs by type assertion, so these three resources now advertise exactly get and list — the same pattern as metrics.k8s.io. Clients that try to watch anyway receive a clean pre-stream 405 MethodNotSupported instead of an idle stream. Watch is unchanged for the dispatcher-backed resources (the kubescape components rely on it), pinned by a keep-side regression test. Refs #318, #320 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
Both files declared "package workloadconfigurationscansummary"; compilation succeeded only because the import alias (vsumstorage) hid the mismatch. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: Matthias Bertschy <matthias.bertschy@gmail.com>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Summary:
|
Base automatically changed from
fix/318-effective-feature-gates-idle-watch
to
main
June 18, 2026 08:02
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.
Summary
Hybrid watch strategy follow-up to #330: keep the watch verb where watch genuinely works (the dispatcher-backed resources that node-agent, synchronizer, and operator rely on) and stop advertising it where it can never work — the three computed ("virtual CRD") resources that are generated on the fly and never stored:
configurationscansummariesvulnerabilitysummariesgeneratednetworkpoliciesAfter #330 these resources serve an idle watch (open, event-free) — harmless but dishonest: discovery advertises
watch, the server accepts, and no event ever arrives. The same applies to the mutating verbs: the storage layer rejects all mutations on computed resources, yet discovery advertised them.How
The endpoints installer decides verbs per resource by type assertion on the registered
rest.Storageobject (installer.go:storage.(rest.Watcher)etc.). The newregistry.ReadOnlyRESTwraps*genericregistry.Storeas a field instead of embedding it (embedding re-promotesWatchand friends), explicitly delegating only:rest.Storage·rest.Scoper·rest.Getter·rest.Lister(incl.ConvertToTable, sokubectl gettables keep working) ·rest.SingularNameProviderDiscovery for the three resources therefore lists exactly
get,list— the same pattern asmetrics.k8s.io. Effects:IsListWatchable(requires bothlist+watchverbs) → it now skips these resources entirely instead of holding silent watches.?watch=trueanyway get a clean pre-stream 405 MethodNotSupported (handlers/get.go), with standard reflector backoff.registry.RESTstill satisfiesrest.Watcher.Also fixes a copy-pasted package name:
vulnerabilitysummary/declaredpackage workloadconfigurationscansummary(hidden by the import alias).Testing
TestReadOnlyRESTInterfaceSurfacepins the installer-visible interface surface (not Watcher/Creater/Updater/GracefulDeleter/CollectionDeleter; is Getter/Lister/Scoper/SingularNameProvider)TestRESTKeepsWatchVerb— keep-side regression guardvar _guards for the required interfacesmake test),go vetcleankubectl api-resources -o wideshowsget,listfor the three resources; steve no longer logs watch attempts for themRelease note
Refs #318, #320 · Stacked on #330
🤖 Generated with Claude Code