← Back to Pull requests

api: add xds translator configuration to EnvoyProxy #10740

Closed
mgs255 closed this pull request without merging on Dec 01, 2026 11:03 UTC
View on GitHub
mgs255 mgs255 commented on Nov 30, 2026 13:02 UTC
Author

Proposal for extension to EnvoyProxy API to allow configuration of metadata generation.

What this PR does / why we need it:
Replaces the LbEndpointMetadata runtime flag proposed in #10224 with a proper EnvoyProxy API, per review feedback (flags are for temporary rollouts, xDS size is a long-term concern, and per-proxy control is
preferable).

Adds optional EnvoyProxy.spec.xds.metadata.endpoint, which attaches backend identity to each endpoint in the generated xDS under the envoy-gateway.backend filter metadata namespace. It's usable in access
logs, e.g. %METADATA(UPSTREAM_HOST:envoy-gateway:backend:name)%.

- Disabled when unset, to avoid churning existing xDS and test fixtures. Setting endpoint (even empty) enables it with all fields.
- kind, name, namespace and sectionName can each be set to false to reduce xDS size.
- The xds.metadata nesting leaves room for other optional xDS settings later without a breaking change.

API only (types, generated code, API docs). The implementation will follow once the API is agreed.

Which issue(s) this PR fixes:
Related to #10224

---

PR Checklist

- [x] Authorship & ownership: Coding agents / AI assistants are welcome, but I have reviewed every change, understand how and why it works, can explain and maintain it, and take full responsibility for this
PR. I have not submitted generated output I do not understand.
- [x] DCO: All commits are signed off (git commit -s). See DCO: Sign your work.
- [ ] API agreed first: If this PR contains API changes (changes under /api), the API was discussed and agreed before the implementation. The API change can be in a separate PR, or in the same PR, but
the API must be agreed before implementation. N/A if this PR does not contain API changes.
- [ ] Required checks pass: make generate gen-check, make lint, and the unit-test/coverage build pass. (Flaky e2e failures are not considered breakages, but gen-check, lint, and coverage MUST
pass.)
- [x] Tests added/updated: N/A: API types only, no behavioral code yet.
- [x] Docs: N/A: generated API reference is updated; user docs will come with the implementation.
- [x] Release notes: N/A: not user-visible until implemented.
- [x] Generated files committed: Ran make gen-check and committed the result if API/helm charts/modules changed.
- [ ] Scope & compatibility: The PR is reasonably scoped (no unrelated changes) and preserves backward compatibility, or any breaking change is called out above and documented in
release-notes/current/breaking_changes/.
- [ ] Codex review: Requested a Codex review and addressed all of its comments.
- [ ] Copilot review: Requested a Copilot review and addressed all of its comments.

Diff: 265 lines (+265 / -0) across 5 files Reviewer: zirain Review duration: 1321m
All Vouch review confidence checks passed
Residual risk 0.11 = Change Risk (0.65) × (1 − Review Confidence (0.84)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.65 · 265 lines diff across 5 files
0.65
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.72 · 5 substantive comment(s)
0.72
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 50%
83%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size diff_size
0.334
Sensitive Paths sensitive_paths
0.065
Real PR Conversation Timeline
11 items
netlify[bot] netlify[bot] commented on Nov 30, 2026 13:02 UTC
Bot

<span aria-hidden="true">✅</span> Deploy Preview for cerulean-figolla-1f9435 ready!


Built without sensitive environment variables

| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | 0eef4bb7b6fc68954ad4cbfadd44a8b3500465ac |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6b0d746e1c23005bc8289af3 |
|<span aria-hidden="true">😎</span> Deploy Preview | https://deploy-preview-10740--cerulean-figolla-1f9435.netlify.app |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br />!QR Code<br /><br />_Use your smartphone camera to open QR code link._</details> |
---
<!-- cerulean-figolla-1f9435 Preview -->
_To edit notification comments on pull requests, go to your Netlify project configuration._

chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 13:11 UTC
Bot

<!-- codex-pull-request-review-summary -->
<!-- codex-review-state:v1 {"code_review":{"commit_sha":"0eef4bb7b6fc68954ad4cbfadd44a8b3500465ac","has_any_findings":true,"has_unresolved_findings":true,"status":"completed"},"security_review":{"commit_sha":null,"has_any_findings":null,"has_unresolved_findings":null,"status":null}} -->

<details>
<summary><strong>Codex Review Summary</strong>: ✅ Completed</summary>

This comment shows the latest Codex review activity on this pull request.

| Review | Status | Commit | Review trigger |
| --- | --- | --- | --- |
| 📝 Code Review | ✅ Completed <relative-time datetime="2026-11-30T13:14:51.267549Z">2026-11-30T13:14:51.267549Z</relative-time> | 0eef4bb | Draft marked ready |

<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Nov 30, 2026 13:14 UTC
    Code Review
    api/v1alpha1/envoyproxy_types.go:1
    @@ -282,6 +287,59 @@ type MergeBackendsConfig struct {
     	Selector *metav1.LabelSelector `json:"selector,omitempty"`
     }
     
    +// XDSConfig configures optional aspects of the generated xDS.
    +type XDSConfig struct {
    +	// Metadata configures the metadata that Envoy Gateway attaches to resources in the generated xDS.
    +	//
    +	// +optional
    +	Metadata *XDSMetadataConfig `json:"metadata,omitempty"`
    +}
    +
    +// XDSMetadataConfig configures the metadata attached to resources in the generated xDS.
    +type XDSMetadataConfig struct {
    +	// Endpoint configures Envoy Gateway to attach the identity of the backend as metadata on every
    +	// endpoint in the generated xDS, under the `envoy-gateway.backend` filter metadata namespace.
    +	// This makes it available to Envoy's `%METADATA(UPSTREAM_HOST:...)%` operator, for example in
    +	// access logs: `%METADATA(UPSTREAM_HOST:envoy-gateway:backend:name)%`.

    <sub><sub>!P2 Badge</sub></sub> Use one namespace in the endpoint metadata contract

    When an implementer or user follows this new contract, these statements select different metadata locations: the expression treats envoy-gateway as the filter-metadata namespace and backend/name as its field path (the same syntax exercised by %METADATA(ROUTE:envoy-gateway:resources)% in test/e2e/testdata/accesslog-otel.yaml:37), while the preceding sentence calls envoy-gateway.backend the namespace. Depending on which statement the implementation follows, either lookups using the advertised namespace or the provided access-log expression will return no value; document this as namespace envoy-gateway plus a backend field, or change the expression to match the dotted namespace.

    Useful? React with 👍 / 👎.

    <!-- codex-code-review-finding:v1 -->

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Nov 30, 2026 13:14 UTC
    Reviewer

    <!-- codex-review-receipt:v1 -->

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 0eef4bb7b6

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • If Codex has suggestions, it will comment; otherwise it will react with 👍.

    When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

    </details>

    codecov[bot] codecov[bot] commented on Nov 30, 2026 13:19 UTC
    Bot

    Codecov Report


    :white_check_mark: All modified and coverable lines are covered by tests.
    :white_check_mark: Project coverage is 82.83%. Comparing base (a50bb96) to head (0eef4bb).

    <details><summary>Additional details and impacted files</summary>

    @@            Coverage Diff             @@
    ##             main   #10740      +/-   ##
    ==========================================
    - Coverage   82.84%   82.83%   -0.01%     
    ==========================================
      Files         279      279              
      Lines       44687    44687              
    ==========================================
    - Hits        37019    37018       -1     
    - Misses       7667     7668       +1     
      Partials        1        1              
    

    </details>

    :umbrella: View full report in Codecov by Harness.
    :loudspeaker: Have feedback on the report? Share it here.
    <details><summary> :rocket: New features to boost your workflow: </summary>

  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

  • </details>

    zirain zirain commented on Nov 30, 2026 13:23 UTC
    Reviewer

    overall LGTM

    zhaohuabing zhaohuabing commented on code on Dec 01, 2026 03:14 UTC
    Code Review
    api/v1alpha1/envoyproxy_types.go:1
    @@ -282,6 +287,59 @@ type MergeBackendsConfig struct {
     	Selector *metav1.LabelSelector `json:"selector,omitempty"`
     }
     
    +// XDSConfig configures optional aspects of the generated xDS.
    +type XDSConfig struct {
    +	// Metadata configures the metadata that Envoy Gateway attaches to resources in the generated xDS.
    +	//
    +	// +optional
    +	Metadata *XDSMetadataConfig `json:"metadata,omitempty"`
    +}
    +
    +// XDSMetadataConfig configures the metadata attached to resources in the generated xDS.
    +type XDSMetadataConfig struct {
    +	// Endpoint configures Envoy Gateway to attach the identity of the backend as metadata on every
    +	// endpoint in the generated xDS, under the `envoy-gateway.backend` filter metadata namespace.

    nit: the namespace is envoy-gateway and backend is a key inside it, which is what the %METADATA(UPSTREAM_HOST:envoy-gateway:backend:name)% example assumes. As written, this reads like one dotted namespace envoy-gateway.backend.

    	// endpoint in the generated xDS, under the `backend` key of the `envoy-gateway` filter metadata namespace.
    

    zhaohuabing zhaohuabing commented on code on Dec 01, 2026 03:14 UTC
    Code Review
    api/v1alpha1/envoyproxy_types.go:1
    @@ -282,6 +287,59 @@ type MergeBackendsConfig struct {
     	Selector *metav1.LabelSelector `json:"selector,omitempty"`
     }
     
    +// XDSConfig configures optional aspects of the generated xDS.
    +type XDSConfig struct {
    +	// Metadata configures the metadata that Envoy Gateway attaches to resources in the generated xDS.
    +	//
    +	// +optional
    +	Metadata *XDSMetadataConfig `json:"metadata,omitempty"`
    +}
    +
    +// XDSMetadataConfig configures the metadata attached to resources in the generated xDS.
    +type XDSMetadataConfig struct {
    +	// Endpoint configures Envoy Gateway to attach the identity of the backend as metadata on every
    +	// endpoint in the generated xDS, under the `envoy-gateway.backend` filter metadata namespace.
    +	// This makes it available to Envoy's `%METADATA(UPSTREAM_HOST:...)%` operator, for example in
    +	// access logs: `%METADATA(UPSTREAM_HOST:envoy-gateway:backend:name)%`.
    +	//
    +	// The metadata is added to every endpoint, which increases xDS size. Individual fields can be
    +	// disabled to reduce it.
    +	//
    +	// Disabled when unset; specifying this field at all (even empty) enables it, with every field
    +	// included.
    +	//
    +	// +optional
    +	Endpoint *EndpointMetadataConfig `json:"endpoint,omitempty"`
    +}
    +
    +// EndpointMetadataConfig selects which backend identity fields are emitted as endpoint metadata.
    +// Every field is included unless explicitly set to false.
    +type EndpointMetadataConfig struct {

    Could we drop the per-field toggles and just let a non-nil value enable it, like mergeBackends? Turning off a field saves only a few bytes per endpoint, and a fixed set of keys is easier to rely on in access logs. We can add them later if needed.

    zhaohuabing zhaohuabing commented on Dec 01, 2026 03:27 UTC
    Contributor

    Reading #9408, both cases look covered already by the backend identity on each endpoint group. I tried %CEL(xds.upstream_host_locality_metadata.filter_metadata['envoy-gateway']['resources'][0]['name'])% against a cluster with two weighted backendRefs in different namespaces, and every log line named the backend that served the request.

    Maybe there's a case this doesn't cover that I'm not seeing? If not, documenting that expression might be enough, without new API or per-endpoint xDS.

    mgs255 mgs255 commented on Dec 01, 2026 11:03 UTC
    Author

    @zhaohuabing Thanks so much! %CEL(xds.upstream_host_locality_metadata.filter_metadata['envoy-gateway']['resources'][0]['name'])% was completely new to me. I switch over to use that in our dev clusters and that just works out of the box no patches or api changes required.

            accessLog:
              settings:
              - format:
                  type: JSON
                  json:
                    ...
                    # This needs changes in envoy-gateway to attach metadata to endpoints - available in our patched version
                    #upstream_service: "%METADATA(UPSTREAM_HOST:envoy-gateway:backend:name)%"
                    #namespace_extracted: "%METADATA(UPSTREAM_HOST:envoy-gateway:backend:namespace)%"
                    upstream_service: "%CEL(xds.upstream_host_locality_metadata.filter_metadata['envoy-gateway']['resources'][0]['name'])%"
                    namespace_extracted: "%CEL(xds.upstream_host_locality_metadata.filter_metadata['envoy-gateway']['resources'][0]['namespace'])%"
                  ...
    

    I will close this and the other PR.

    Reviewers
    Assignees
    mgs255 mgs255
    Labels
    risk: low confidence: 83.8% reviewed sensitive_module
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 65.4% (HIGH) · Higher = larger blast radius
    65.4%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 83.8% · Lower = rushed or shallow review
    83.8%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 10.6% · Safe to merge
    10.6%