Skip to content

feat(agent): refresh xDS clusters on registry changes - #71

Merged
bpalermo merged 1 commit into
mainfrom
fix/agent-dynamic-cluster-refresh
Jun 7, 2026
Merged

bpalermo merged 1 commit into
mainfrom
fix/agent-dynamic-cluster-refresh

Conversation

@bpalermo

@bpalermo bpalermo commented Jun 7, 2026

Copy link
Copy Markdown
Owner

Problem

The agent built clusters/endpoints/virtual-hosts only once, in the xDS server's PreListen (LoadClustersFromRegistry). Nothing rebuilt them when the registry changed, and RemoveEndpoint/RemoveCluster were never called. So a service registered after the agent started had no cluster or route — outbound requests to it returned 404 — until the agent was restarted.

Surfaced during the Cloud Map full-traffic e2e: a managed client curling a managed echo (registered after agent start) got 404 server: envoy, and the agent-proxy config_dump showed dynamic_active_clusters: 0 / dynamic_route_configs: 0 despite echo being live in the registry.

Change

  • registrar registry (registry/internal/registrar): emit a coalesced, non-blocking change signal on every applied watch event, exposed via Changes(). New optional capability registry.ChangeNotifier.
  • agent (agent/internal/xds/server/refresh.go): RegistryRefresher, a manager.Runnable that debounces those signals and rebuilds the cluster snapshot via LoadClustersFromRegistry. No-op if the registry doesn't implement ChangeNotifier (the initial PreListen snapshot still applies).
  • LoadClustersFromRegistry is now a full rebuild, so reloads prune services/endpoints that disappeared from the registry (previously it only accumulated).

Tests

  • registrar: applyEvent signals Changes(); bursts coalesce to one pending signal.
  • cache: reload prunes stale clusters.
  • refresher: rebuilds the cluster on a change signal (debounced); no-op + clean stop when the registry isn't a notifier.

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.

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]>
@bpalermo
bpalermo merged commit 3d31a46 into main Jun 7, 2026
10 checks passed
@bpalermo
bpalermo deleted the fix/agent-dynamic-cluster-refresh branch June 7, 2026 13:49
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.

1 participant