Repository navigation
fix: restrict hub reconciliation to member reserved namespaces - #466
Open
Chen Yu (michaelawyu) wants to merge 1 commit into
Open
Chen Yu (michaelawyu) wants to merge 1 commit into
Chen Yu (michaelawyu) wants to merge 1 commit into
Conversation
Member agents only write EndpointSliceExports, InternalServiceExports and InternalServiceImports to their reserved hub namespaces (fleet-member-*). Hub controllers previously reconciled these objects in any namespace, so an object created elsewhere could claim a ServiceImport, distribute endpoints to arbitrary namespaces, add clusters to ServiceImport status, or replace a member's Traffic Manager endpoint target. - Add objectmeta.IsMemberReservedNamespace and objectmeta.MemberReservedNamespacePredicate, based on the new hubconfig.HubNamespacePrefix. - Filter the primary watches and ServiceImport map functions of the hub EndpointSliceExport, InternalServiceExport and InternalServiceImport controllers. - Exclude InternalServiceExports outside reserved namespaces from the field index shared by the ServiceImport and TrafficManagerBackend controllers. - Move the Gateway API E2E synthetic exports into test-owned reserved namespaces. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: michaelawyu <chenyu1@microsoft.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #466 +/- ##
==========================================
+ Coverage 76.32% 76.52% +0.20%
==========================================
Files 77 77
Lines 7669 7681 +12
==========================================
+ Hits 5853 5878 +25
+ Misses 1402 1392 -10
+ Partials 414 411 -3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
What type of PR is this?
/kind bug
What this PR does / why we need it:
Member agents only write EndpointSliceExports, InternalServiceExports and InternalServiceImports to their reserved hub namespaces (
fleet-member-*). Hub controllers previously reconciled these objects in any namespace. An object created elsewhere could:This PR:
objectmeta.IsMemberReservedNamespaceandobjectmeta.MemberReservedNamespacePredicate, based on a newhubconfig.HubNamespacePrefix.HubNamespaceNameFormatis now built from that prefix;Forwatch of the hub EndpointSliceExport, InternalServiceExport and InternalServiceImport controllers. The ServiceImport map functions apply the same filter;fleet-member-*namespaces.Which issue(s) this PR fixes:
Fixes # N/A (no tracking issue)
Requirements:
make reviewablefor basic local testHow has this code been tested
go build ./...: passedgo vet ./pkg/common/... ./pkg/controllers/hub/...: passedgo vet -tags e2e ./test/e2e/...: passedKUBEBUILDER_ASSETS="$(hack/tools/bin/setup-envtest-release-0.22 use 1.35.0 -p path)" CGO_ENABLED=1 go test -race -count=1 ./pkg/common/objectmeta ./pkg/common/hubconfig ./pkg/controllers/hub/endpointsliceexport ./pkg/controllers/hub/internalserviceexport ./pkg/controllers/hub/internalserviceimport ./pkg/controllers/hub/serviceimport ./pkg/controllers/hub/trafficmanagerbackend ./pkg/controllers/hub/gatewayresolver: passedGOTOOLCHAIN=go1.26.10 make lint: passed. The toolchain is pinned so golangci-lint is built with the same Go version as CI.New regression tests:
With
IsMemberReservedNamespacetemporarily forced to return true, all of these failed.Not run:
make reviewable(lint, vet and goimports were run individually) and Azure E2E, including the updated Gateway API E2E test.Special notes for your reviewer
Forrather thanWithEventFilter.WithEventFilterwould also drop ServiceImport events, which come from application namespaces.fleet-member-prefix only. It doesn't require the namespace to equalfleet-member-<ClusterID>.ConflictingExports, and the TrafficManagerBackend export watch still queues reconciles for such exports. Neither can change the resolved backends or the Traffic Manager endpoints.