Skip to content

refactor(common): split the Envoy-free gRPC server shell out of common/xds (registrar -2.55 MiB, -2 modules) - #1164

Merged
bpalermo merged 3 commits into
mainfrom
refactor/grpcserver-split
Oct 4, 2026
Merged

bpalermo merged 3 commits into
mainfrom
refactor/grpcserver-split

Conversation

@bpalermo

@bpalermo bpalermo commented Oct 3, 2026

Copy link
Copy Markdown
Owner

What

common/xds held two unrelated things:

  1. the generic gRPC lifecycle shell (Server, ServerConfig, ServerCallback, liveness/readiness, the bind gate), and
  2. the Envoy xDS server (XdsServer).

The registrar and the agent's CNI server embed only (1), but importing the package also linked (2)'s dependencies into the registrar: go-control-plane's pkg/server and pkg/cache, every envoy discovery service proto, the cluster/listener/HCM/accesslog config protos those pull, and the ratelimit module.

This PR moves (1), unchanged, to a new Envoy-free common/grpcserver (renames, so history is kept). common/xds keeps XdsServer, which now embeds grpcserver.Server. It is a pure refactor:

  • The logger name stays "xds", so existing log queries still match.
  • Two read-only accessors (GRPCServer(), Config()) replace the unexported-field reads the XdsServer tests used to make from inside the same package. No test case was removed.
  • CLAUDE.md, the runbook's race-gate example and the CI race "hot packages" list now name common/grpcserver. The CI list keeps common/xds too.

Measured

bazel build (fastbuild), stat + go version -m:

binary before after Δ
registrar 60,274,892 B, 105 modules 57,596,076 B, 103 modules -2.55 MiB (-4.4%), drops github.com/envoyproxy/go-control-plane and .../ratelimit
agent 68,869,868 B 68,873,932 B +4 KiB (the accessors)

Before this PR, bazel query 'somepath(//registrar/cmd/registrar:registrar, @com_github_envoyproxy_go_control_plane//...)' went registrar/internal/server → common/xds → pkg/cache/v3. It is now empty. The 30 targets only common/xds contributed to the registrar's closure came from this query (11 go-control-plane pkg/*, 16 envoy protos, 2 ratelimit):

let R = deps(//registrar/cmd/registrar:registrar) in
let X = kind(go_library, $R intersect //...) except //common/xds:xds in
deps(//common/xds:xds) except deps(labels("deps", $X) except rdeps($R, //common/xds:xds))

The registrar still links go-control-plane/envoy protos through common/gammaproject → common/extensionfilter (cross-cluster config export), and it needs them.

Checks

  • bazel test --config=race //common/grpcserver:all //common/xds:all //agent/internal/cni/server:all //agent/internal/xds/server:all //registrar/internal/server:all: 5/5 pass
  • bazel test //agent/cmd/... //registrar/... //agent/internal/cmd/... //common/...: 47/47 pass
  • bazel build //...: ok
  • bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation on the touched trees: clean
  • make format-check: clean

Found by the dead-code / dependency audit (2026-10-03).

🤖 Generated with Claude Code

https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr

…n/xds so the registrar stops linking go-control-plane

common/xds held two things: the generic gRPC lifecycle shell (Server,
ServerConfig, ServerCallback, liveness/readiness, the bind gate) and the
Envoy xDS server (XdsServer). The registrar and the agent's CNI server only
embed the shell, but importing the package linked go-control-plane's
pkg/server and pkg/cache, the envoy service protos (ADS/LDS/CDS/EDS/RDS/SDS,
runtime, extension config), the cluster/listener/HCM/accesslog config protos
those pull, and the ratelimit module into the registrar.

The shell moves, unchanged, to common/grpcserver (git mv, history kept);
common/xds keeps XdsServer, which now embeds grpcserver.Server. The logger
name stays "xds" so existing log queries still match. Two read-only
accessors (GRPCServer, Config) replace the unexported-field reads the
XdsServer tests used to make from the same package.

Measured (bazel build, fastbuild, `go version -m` / stat):
  registrar  60,274,892 -> 57,596,076 bytes (-2.55 MiB, -4.4%)
             105 -> 103 modules (drops github.com/envoyproxy/go-control-plane
             and .../ratelimit)
  agent      68,869,868 -> 68,873,932 bytes (+4 KiB, the accessors)
`bazel query 'somepath(//registrar/cmd/registrar:registrar,
@com_github_envoyproxy_go_control_plane//...)'` is now empty. The
registrar still links go-control-plane/envoy protos via
common/gammaproject -> common/extensionfilter, which it needs.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
@bpalermo
bpalermo force-pushed the refactor/grpcserver-split branch from 3126fb0 to aebbed1 Compare October 4, 2026 03:00
@bpalermo
bpalermo merged commit 2ea7058 into main Oct 4, 2026
24 checks passed
@bpalermo
bpalermo deleted the refactor/grpcserver-split branch October 4, 2026 03:32
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