Skip to content

feat(notes): add multi-cluster support for notes webhook subject lookup#510

Merged
scotwells merged 7 commits intomainfrom
feat/notes-multicluster-webhook
Feb 27, 2026
Merged

feat(notes): add multi-cluster support for notes webhook subject lookup#510
scotwells merged 7 commits intomainfrom
feat/notes-multicluster-webhook

Conversation

@scotwells
Copy link
Contributor

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

  • Unit tests pass
  • End-to-end tests validate notes work with project control plane resources

@joggrbot
Copy link
Contributor

joggrbot bot commented Feb 27, 2026

📝 Documentation Analysis

All docs are up to date! 🎉


✅ Latest commit analyzed: f54cee1 | Powered by Joggr

@scotwells scotwells force-pushed the feat/notes-multicluster-webhook branch from e7fae2a to f753c10 Compare February 27, 2026 18:47
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>
@scotwells scotwells force-pushed the feat/notes-multicluster-webhook branch from f753c10 to 50c73ea Compare February 27, 2026 19:03
scotwells and others added 4 commits February 27, 2026 13:16
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>
@cla-assistant
Copy link

cla-assistant bot commented Feb 27, 2026

CLA assistant check
All committers have signed the CLA.

@cla-assistant
Copy link

cla-assistant bot commented Feb 27, 2026

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

scotwells and others added 2 commits February 27, 2026 15:19
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>
@scotwells scotwells marked this pull request as ready for review February 27, 2026 22:24
@scotwells scotwells merged commit 7046457 into main Feb 27, 2026
8 checks passed
@scotwells scotwells deleted the feat/notes-multicluster-webhook branch February 27, 2026 22:26
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.

2 participants