feat: add runtime fraction to EnvoyExtensionPolicy - #8849
Conversation
✅ Deploy Preview for cerulean-figolla-1f9435 ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 50ba8509bf
ℹ️ 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".
| } | ||
| if extensionsUsePercentage(r.EnvoyExtensions) { | ||
| fallback := irListener.Routes[i].DeepCopy() | ||
| fallback.EnvoyExtensions = &ir.EnvoyExtensionFeatures{} |
There was a problem hiding this comment.
Keep non-sampled extensions on fallback routes
Clearing fallback.EnvoyExtensions makes unsampled traffic skip every extension on that route, including ones whose percentage is unset (documented as 100%). In a mixed policy (for example, lua.percentage=20 plus ExtProc without percentage), only 20% of requests will execute ExtProc because the fallback route has no extension config at all. This breaks per-extension semantics and affects both route- and gateway-targeted paths where the same fallback reset is used.
Useful? React with 👍 / 👎.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8849 +/- ##
==========================================
+ Coverage 74.57% 74.59% +0.02%
==========================================
Files 250 250
Lines 39751 39839 +88
==========================================
+ Hits 29644 29719 +75
- Misses 8056 8066 +10
- Partials 2051 2054 +3 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Signed-off-by: Adam Buran <aburan28@gmail.com>
50ba850 to
079f74d
Compare
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions! |
|
can we call it percent to keep it idiomatic with https://gateway-api.sigs.k8s.io/reference/api-spec/1.5/spec/#httprequestmirrorfilter |
|
the design for this, will require more thought should we wait until we've moved to per route configs @zhaohuabing ? |
|
The PR is trying to solve a per-filter fraction, but the implementation is per-route (forking the route into a sampled entry + a fallback clone), so the mechanism doesn't map cleanly onto the problem — and route duplication splits per-route state like stats, rate-limit descriptors, and session persistence. The clearer model is sampling at the filter level. Envoy supports this on ext_authz via filter_enabled (a RuntimeFractionalPercent), but there's no consistent equivalent across filters — rbac has none, fault only has per-behavior abort/delay percentages, and cors's filter_enabled lives on the route-level CorsPolicy, not the filter. So ExtProc/Lua/Wasm have no native knob today. I checked envoyproxy/envoy#42912 in case it helped — it's a per-route chain selector with no sampling primitive, so it'd still need a runtime_fraction at the route to pick a chain, reintroducing the same duplication. The cleanest fix would be Envoy supporting a generic filter_enabled runtime fraction on the HttpFilter wrapper itself (which today only has disabled), e.g.: httpFilters:
- name: envoy.filters.http.ext_proc/envoyextensionpolicy/default/policy-for-http-route/extproc/0
filterEnabled: # proposed: generic per-filter runtime fraction
defaultValue:
numerator: 50
typedConfig:
'@type': type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor
grpcService:
envoyGrpc:
authority: grpc-backend.envoy-gateway:8000
clusterName: envoyextensionpolicy/default/policy-for-http-route/0
timeout: 10s
processingMode:
requestHeaderMode: SKIP
requestTrailerMode: SKIP
responseHeaderMode: SKIPThat would cover all extension filters uniformly without touching the route. Might be worth raising upstream before we commit to the per-route approach here. cc @wbpcode you have a lot more Envoy expertise here—do you think the generic filter_enabled runtime fraction approach would work on the Envoy side? |
|
If this feature actually is EG wants, I will suggest to add a new HTTP filter which works as a wrapper to avoid impact Envoy core but at same time, could achieve same target that Huabing referred. |
|
@aburan28 could you open an issue to describe your use case in more detail and gather feedback from the community? If this is something we need, we could then open an upstream Envoy issue, as @wbpcode suggested, to explore adding generic filter-level runtime fraction support rather than modeling it at the route level. |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions! |
What type of PR is this?
feature
What this PR does / why we need it
This PR adds percentage-based runtime fraction support to
EnvoyExtensionPolicyfor Wasm, ExtProc, and Lua extensions.Envoy Gateway currently lets users attach extension filters through
EnvoyExtensionPolicy, but it does not expose Envoy'sruntime_fractionbehavior for those filters. Users who need gradual rollout or sampled execution of extensions have to patch generated xDS manually. This change lets users configure apercentagefraction directly on each extension entry.This recreates and refreshes the closed/unmerged work from #8374 on top of current
main.How it works
percentagefields toWasm,ExtProc, andLuaEnvoyExtensionPolicy API types usinggwapiv1.Fraction.runtime_fraction.Testing
go test ./internal/xds/utils/fractionalpercent ./internal/xds/translator ./internal/gatewayapigo test ./internal/gatewayapi -run 'TestAppendFallbackRoutes|TestExtensionsUsePercentage'go test ./internal/xds/translator -run 'TestApplyRuntimeFractionToRouteMatch|TestPatchRouteAppliesRuntimeFractionForExtensions'make -k gen-checkWhich issue(s) this PR fixes
None linked.
Release Notes
Added percentage-based runtime fraction support for EnvoyExtensionPolicy Wasm, ExtProc, and Lua extensions.