Repository navigation
feat(agent): refresh xDS clusters on registry changes - #71
Merged
Merged
Conversation
Clusters, endpoints, and virtual hosts were built only once, during the xDS server's PreListen (LoadClustersFromRegistry). Nothing rebuilt them when the registry changed, so any service registered after the agent started had no cluster/route and was unreachable (outbound requests 404'd) until the agent restarted. - registrar registry: emit a coalesced, non-blocking change signal on every applied watch event, exposed via Changes() (new registry.ChangeNotifier optional capability). - agent: add RegistryRefresher, a manager runnable that debounces those signals and rebuilds the cluster snapshot via LoadClustersFromRegistry. No-op when the registry can't notify (initial PreListen snapshot still applies). - make LoadClustersFromRegistry a full rebuild so reloads prune services and endpoints that disappeared from the registry. Co-Authored-By: Claude Opus 4.8 <[email protected]>
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.
Problem
The agent built clusters/endpoints/virtual-hosts only once, in the xDS server's
PreListen(LoadClustersFromRegistry). Nothing rebuilt them when the registry changed, andRemoveEndpoint/RemoveClusterwere never called. So a service registered after the agent started had no cluster or route — outbound requests to it returned404— until the agent was restarted.Surfaced during the Cloud Map full-traffic e2e: a managed
clientcurling a managedecho(registered after agent start) got404 server: envoy, and the agent-proxyconfig_dumpshoweddynamic_active_clusters: 0/dynamic_route_configs: 0despiteechobeing live in the registry.Change
registry/internal/registrar): emit a coalesced, non-blocking change signal on every applied watch event, exposed viaChanges(). New optional capabilityregistry.ChangeNotifier.agent/internal/xds/server/refresh.go):RegistryRefresher, amanager.Runnablethat debounces those signals and rebuilds the cluster snapshot viaLoadClustersFromRegistry. No-op if the registry doesn't implementChangeNotifier(the initialPreListensnapshot still applies).LoadClustersFromRegistryis now a full rebuild, so reloads prune services/endpoints that disappeared from the registry (previously it only accumulated).Tests
applyEventsignalsChanges(); bursts coalesce to one pending signal.bazel test //registry/internal/registrar:... //agent/internal/xds/cache:... //agent/internal/xds/server:... //agent/internal/cmd:...all pass.Note
This makes post-startup services routable. End-to-end pod→pod traffic also needs the inbound mTLS SDS secrets to resolve, which is addressed separately (validation-context naming in #70, and the CNI container-PID / workload-SVID subscription in a follow-up). Full live traffic e2e will be run once those land together.