Skip to content

feat: add contentTypes config for BackendTrafficPolicy compression#9522

Open
FAUST-BENCHOU wants to merge 1 commit into
envoyproxy:mainfrom
FAUST-BENCHOU:feat/compression-content-types
Open

feat: add contentTypes config for BackendTrafficPolicy compression#9522
FAUST-BENCHOU wants to merge 1 commit into
envoyproxy:mainfrom
FAUST-BENCHOU:feat/compression-content-types

Conversation

@FAUST-BENCHOU

@FAUST-BENCHOU FAUST-BENCHOU commented Jul 19, 2026

Copy link
Copy Markdown

What this PR does / why we need it:

BackendTrafficPolicy compression already supports minContentLength, but there is no way to configure which response Content-Types are eligible for compression. Users who need custom types outside Envoy's defaults currently have to add an EnvoyPatchPolicy on top of the compressor config.

This PR adds an optional contentTypes field on Compression and wires it through IR to the Envoy compressor filter's content_type setting. When unset, Envoy's default content types are unchanged.

Which issue(s) this PR fixes:

Fixes #9511


PR Checklist

  • 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.
  • 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.)
  • Tests added/updated: New/changed code is covered by appropriate tests. N/A if this PR does not contain code changes.
  • Docs: User-facing changes update the docs, either in this PR or a follow-up PR. N/A if this PR does not contain user-facing changes.
  • Release notes: For any non-trivial change, added a release-note fragment under release-notes/current/<section>/<pr-number>-<slug>.md (see release-notes/current/README.md for sections and naming). N/A if this PR does not contain non-trivial changes.
  • 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.

@FAUST-BENCHOU
FAUST-BENCHOU requested a review from a team as a code owner July 19, 2026 07:33
@netlify

netlify Bot commented Jul 19, 2026

Copy link
Copy Markdown

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit ce22a3a
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a5c88d0c81edb0008b8822a
😎 Deploy Preview https://deploy-preview-9522--cerulean-figolla-1f9435.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@FAUST-BENCHOU

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 792b3a2e8c

ℹ️ About Codex in GitHub

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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread internal/xds/translator/compressor.go
Comment thread api/v1alpha1/compression_types.go
Signed-off-by: zhoujinyu <2319109590@qq.com>
@FAUST-BENCHOU
FAUST-BENCHOU force-pushed the feat/compression-content-types branch from 792b3a2 to ce22a3a Compare July 19, 2026 08:20
@zirain

zirain commented Jul 21, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: ce22a3af01

ℹ️ About Codex in GitHub

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".

commonConfig.MinContentLength = wrapperspb.UInt32(*compression.MinContentLength)
}
if len(compression.ContentTypes) > 0 {
commonConfig.ContentType = append([]string{}, compression.ContentTypes...)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve per-route content type settings

When two HTTPRoutes on the same listener configure the same compressor type with different contentTypes, this listener-wide filter config is created only once: patchHCM skips subsequent filters with the same compressorFilterName, and patchRoute only enables that existing filter. As a result, whichever route is visited first supplies the ContentType list for every route using that compressor, so the other route's policy silently compresses the wrong response types or fails to compress its configured types.

Useful? React with 👍 / 👎.

// text/css, text/html, text/plain, text/xml.
//
// +optional
ContentTypes []string `json:"contentTypes,omitempty"`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Keep contentTypes out of metrics compression unless supported

Adding contentTypes to the shared Compression type also exposes it under EnvoyProxy.spec.telemetry.metrics.prometheus.compression because that field reuses this type, but the bootstrap renderer for Prometheus compression only reads Compression.Type and ignores the new list. EnvoyProxy users can now set an accepted/documented contentTypes value that has no effect; either wire it into internal/xds/bootstrap or avoid exposing this BackendTrafficPolicy-specific option through the shared type.

Useful? React with 👍 / 👎.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.51%. Comparing base (265fdeb) to head (ce22a3a).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9522      +/-   ##
==========================================
- Coverage   75.53%   75.51%   -0.02%     
==========================================
  Files         252      252              
  Lines       41646    41646              
==========================================
- Hits        31457    31451       -6     
- Misses       8062     8066       +4     
- Partials     2127     2129       +2     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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.

Compression Content Type configuration

2 participants