Repository navigation
refactor(l4route,edge): one shared L4 backendRef projector in common/l4project (#772) - #783
Merged
Merged
Conversation
…l4project (#772 A8) `buildL4Backends` existed twice, with the same signature and — line by line — the same semantics: `agent/internal/l4route/reconciler.go:466` (node agent, capture-path TCP/TLS/UDP routes, proposal 018 Phase 3b) and `agent/internal/edge/gatewayapi/reconciler.go:946` (edge gateway, proposals 003/018/021). The duplicated `TestBuildL4Backends_*` tests were the symptom the test review flagged ("do not consolidate the tests until the two methods are merged"). Behavioural diff, decided per row (no proposal documents a mesh-vs-edge difference, and #492 — weight:0 = drain — lives in the proxy layer, not here, so both copies already passed an explicit 0 through): backendRef group filter identical (non-empty group skipped) → kept backendRef kind filter identical (kind != Service skipped) → kept empty name identical (skipped) → kept ReferenceGrant check identical logic, different helper (l4route local vs attachment.*) → one impl weight defaulting identical (nil → 1) → kept weight: 0 identical (passed through as drain) → kept namespace defaulting identical (backendRef ns, else route ns) → kept service key identical (serviceref "<ns>/<svc>") → kept cluster naming ONLY real difference: edge is TCP-only, the agent also needs "udp:" clusters → ClusterNameFunc port neither qualifies L4 backends by port → documented missing Service neither resolves existence here (the reconcilers report it via ResolvedRefs) → documented New package `common/l4project` (not `common/gammaproject`: that package's doc scopes it to the HTTPRoute/GRPCRoute → `registryv1.GammaRoute` *proto* projection; L4 backends are a plain Go model and are not exported cross-cluster). It mirrors gammaproject's shape, including the private `backendPermitted`/`backendServiceKey`/`derefBackendNamespace` helpers, and stays free of agent internals — the caller passes a `ClusterNameFunc`, because the "tcp:"/"udp:" cluster naming lives in the agent's Envoy builders. `proxy.L4Backend` becomes a type alias for `l4project.Backend`, so the cache and the Envoy builders are untouched and both reconcilers return the shared type directly instead of converting. Tests: the two `TestBuildL4Backends_*` sets collapse into one table-driven `TestBackends` in `//common/l4project`, a strict superset of both — foreign group, non-Service kind, explicit core group/Service kind, empty name, nil weight → 1, explicit weight 0 as drain (#492), weighted splits, ungranted cross-namespace dropped, granted cross-namespace keeping its own namespace key, a grant naming the wrong route kind, UDP cluster naming, and the empty-input case — plus unit tests for the three helpers. Each reconciler keeps one thin `TestBuildL4Backends_Wiring` case proving it wires the projector with the right cluster namer; l4route's existing rule-level tests (TCP/TLS/UDP) are unchanged. Production code: 117 lines deleted, 24 added across the three touched files; 127 lines added in the shared package (net ~ -30 including its doc comment). Tests: 81 deleted, 19 added in the reconcilers; 280 added in the shared table. Verification: `bazel build //... //test/e2e:e2e_test` OK; `bazel test //...` 101/101 PASSED (incl. `//test/envoy_validate:envoy_validate_test`); `bazel run //:format.check` clean; `bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...` clean; `bazel run //:gazelle` no churn; `bazel mod tidy` idempotent; `scripts/go-deps-audit.sh` exit 0. Cluster validation (data path) is pending and happens separately. Note for the orchestrator: `e2e.yaml` has NO tcp/tls/udp job — its jobs are build, gateway-http, mesh-http, waypoint, replicator, uds, and both conformance profiles are HTTP-only. The L4 path's automated coverage is the unit tests plus `//test/envoy_validate`; end-to-end TCP-floor/TLS-SNI/UDP exercise is a hands-on talos run. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
The new shared L4 projector introduced by the previous commit gets an entry next to its L7 sibling common/gammaproject. Co-Authored-By: Claude Fable 5.1 <[email protected]> Claude-Session: https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr
This was referenced Sep 16, 2026
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.
Phase A8 of #772. Data path (TCP floor / TLS SNI / UDP): no CI e2e covers L4, so this gets the talos-main hitless-rollout validation with the Phase A batch.
refactor(l4route,edge): one shared L4 backendRef projector in common/l4project (#772 A8)
buildL4Backendsexisted twice, with the same signature and — line by line —the same semantics:
agent/internal/l4route/reconciler.go:466(node agent,capture-path TCP/TLS/UDP routes, proposal 018 Phase 3b) and
agent/internal/edge/gatewayapi/reconciler.go:946(edge gateway, proposals003/018/021). The duplicated
TestBuildL4Backends_*tests were the symptom thetest review flagged ("do not consolidate the tests until the two methods are
merged").
Behavioural diff, decided per row (no proposal documents a mesh-vs-edge
difference, and #492 — weight:0 = drain — lives in the proxy layer, not here,
so both copies already passed an explicit 0 through):
backendRef group filter identical (non-empty group skipped) → kept
backendRef kind filter identical (kind != Service skipped) → kept
empty name identical (skipped) → kept
ReferenceGrant check identical logic, different helper
(l4route local vs attachment.*) → one impl
weight defaulting identical (nil → 1) → kept
weight: 0 identical (passed through as drain) → kept
namespace defaulting identical (backendRef ns, else route ns) → kept
service key identical (serviceref "/") → kept
cluster naming ONLY real difference: edge is TCP-only,
the agent also needs "udp:" clusters → ClusterNameFunc
port neither qualifies L4 backends by port → documented
missing Service neither resolves existence here (the
reconcilers report it via ResolvedRefs) → documented
New package
common/l4project(notcommon/gammaproject: that package's docscopes it to the HTTPRoute/GRPCRoute →
registryv1.GammaRouteprotoprojection; L4 backends are a plain Go model and are not exported
cross-cluster). It mirrors gammaproject's shape, including the private
backendPermitted/backendServiceKey/derefBackendNamespacehelpers, andstays free of agent internals — the caller passes a
ClusterNameFunc, becausethe "tcp:"/"udp:" cluster naming lives in the agent's Envoy builders.
proxy.L4Backendbecomes a type alias forl4project.Backend, so the cache andthe Envoy builders are untouched and both reconcilers return the shared type
directly instead of converting.
Tests: the two
TestBuildL4Backends_*sets collapse into one table-drivenTestBackendsin//common/l4project, a strict superset of both — foreigngroup, non-Service kind, explicit core group/Service kind, empty name, nil
weight → 1, explicit weight 0 as drain (#492), weighted splits, ungranted
cross-namespace dropped, granted cross-namespace keeping its own namespace key,
a grant naming the wrong route kind, UDP cluster naming, and the empty-input
case — plus unit tests for the three helpers. Each reconciler keeps one thin
TestBuildL4Backends_Wiringcase proving it wires the projector with the rightcluster namer; l4route's existing rule-level tests (TCP/TLS/UDP) are unchanged.
Production code: 117 lines deleted, 24 added across the three touched files;
127 lines added in the shared package (net ~ -30 including its doc comment).
Tests: 81 deleted, 19 added in the reconcilers; 280 added in the shared table.
Verification:
bazel build //... //test/e2e:e2e_testOK;bazel test //...101/101 PASSED (incl.
//test/envoy_validate:envoy_validate_test);bazel run //:format.checkclean;bazel build --config=lint --@aspect_rules_lint//lint:fail_on_violation //...clean;bazel run //:gazelleno churn;
bazel mod tidyidempotent;scripts/go-deps-audit.shexit 0.Cluster validation (data path) is pending and happens separately. Note for the
orchestrator:
e2e.yamlhas NO tcp/tls/udp job — its jobs are build,gateway-http, mesh-http, waypoint, replicator, uds, and both conformance
profiles are HTTP-only. The L4 path's automated coverage is the unit tests plus
//test/envoy_validate; end-to-end TCP-floor/TLS-SNI/UDP exercise is ahands-on talos run.
docs: list common/l4project in the Core Packages map (#772 A8)
The new shared L4 projector introduced by the previous commit gets an entry
next to its L7 sibling common/gammaproject.
🤖 Generated with Claude Code
https://claude.ai/code/session_01NArCRTfMPZkw4Y97U9Gdsr