feat(notes): add multi-cluster support for notes webhook subject lookup#510
Merged
feat(notes): add multi-cluster support for notes webhook subject lookup#510
Conversation
Contributor
e7fae2a to
f753c10
Compare
The notes webhook was failing to find subject resources that exist in project control planes because it only queried the local cluster. This change injects the multicluster manager into the notes webhooks, enabling them to search for subjects across all engaged clusters. Changes: - Add ListEngagedClusters() method to Provider for cluster iteration - Create ClusterGetter interface and MultiClusterGetter implementation - Update Note and ClusterNote webhooks to search all clusters for subjects - Wire up multicluster manager in controller-manager for note webhooks - Add E2E tests for multi-cluster subject lookups using ConfigMaps/Namespaces The webhook now searches local cluster first, then all project control planes. Graceful fallback to local-only search when Clusters is nil maintains backwards compatibility for unit tests. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
f753c10 to
50c73ea
Compare
Add kubeconfig files that point to organization and project control plane API paths for the notes multi-cluster tests. This allows the tests to access control planes through Milo's aggregated API server paths rather than separate cluster contexts. Also removes the multicluster test exclusion from Taskfile since these tests should now work in CI. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The notes controller doesn't watch project control planes, so the Ready condition will never be set for notes created there. The tests now only verify that owner references are set by the webhook, which is the actual functionality being tested. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of iterating all clusters to find subject resources, the notes webhooks now use the project context from UserInfo.Extra to determine the specific project control plane to query. Changes: - Remove ClusterGetter interface and MultiClusterGetter implementation - Remove ListEngagedClusters() from provider (no longer needed) - Use UserInfo.Extra[ParentKindExtraKey/ParentNameExtraKey] to detect project context and get the specific project control plane client - Pass mcmanager.Manager directly to webhooks instead of ClusterGetter This is more efficient and semantically correct - we only need to check the control plane where the note is being created. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
|
|
The provider was using req.String() (namespace/name format) as the
cluster key, but the webhook only has access to the project name from
ParentNameExtraKey. This caused "cluster not found" errors when the
webhook tried to look up the project control plane.
Changed the provider to use just req.Name as the key, which matches:
- The project name in URL paths (/projects/{name}/control-plane/...)
- The project name in ParentNameExtraKey
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ontext Introduce a reusable ClusterAwareServer wrapper that automatically injects project control plane context from UserInfo.Extra into the request context. This allows webhook handlers to use mccontext.ClusterFrom(ctx) to determine which project control plane the request is targeting. This pattern matches the approach used by external services like the network-services-operator and provides a cleaner separation of concerns. Changes: - Add pkg/webhook/cluster_aware_server.go as an exported library - Update note and clusternote webhooks to use mccontext.ClusterFrom(ctx) - Wrap the webhook server in controller manager with ClusterAwareServer Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
kevwilliams
approved these changes
Feb 27, 2026
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
Notes can now be attached to resources that live in project control planes. Previously, notes could only reference resources in the main cluster, which caused errors when trying to attach notes to project-specific resources like Domains.
What changed
The notes webhook now searches across all connected clusters when looking up the resource a note references. It checks the main cluster first, then looks in any active project control planes.
Test plan