Skip to content

Revert LuaPerRoute source materialization for Lua - #9426

Merged
arkodg merged 4 commits into
envoyproxy:mainfrom
arkodg:revert-lua-per-route-8355-8598
Jul 11, 2026
Merged

arkodg merged 4 commits into
envoyproxy:mainfrom
arkodg:revert-lua-per-route-8355-8598

Conversation

@arkodg

@arkodg arkodg commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

This reverts commit 80b2762.
This reverts commit f31ac4e.

Gateway-targeted Lua is currently lowered into LuaPerRoute source code on every route. With large route tables, that duplicates identical scripts across
route entries and worker Lua runtime state, matching the memory regression reported in #9355.

Restore listener-level Lua source and route-level filter enablement. This backs out the LuaPerRoute drain mitigation so we stop the route-count memory
amplification while a scope-aware fix is worked through.

Fixes: #9355

@arkodg
arkodg requested a review from a team as a code owner July 7, 2026 00:45
@netlify

netlify Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit b930e4b
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6a4fd1069a43b00008563592
😎 Deploy Preview https://deploy-preview-9426--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.

arkodg added 2 commits July 7, 2026 03:48
…ner drain (envoyproxy#8598)"

This reverts commit 80b2762.

Why:
- Back out the LuaPerRoute stabilization layer together with envoyproxy#8355 while
  investigating the Gateway-scoped Lua memory regression from envoyproxy#9355.
- envoyproxy#8598 only stabilizes per-route Lua HCM slot names; it still leaves Lua
  source materialized per route, so it is not sufficient for the memory issue.

Test plan:
- `go test ./internal/xds/translator`

Signed-off-by: Arko Dasgupta <[email protected]>
…proxy#8355)"

This reverts commit f31ac4e.

Why:
- envoyproxy#8355 materialized Gateway-targeted Lua as per-route LuaPerRoute source code.
- With large route tables, identical Gateway-scoped scripts are duplicated across
  route entries and worker Lua runtime state, matching the memory regression
  reported in envoyproxy#9355.
- Restoring listener-level Lua source avoids scaling the Gateway-scoped script
  with route count.

Test plan:
- `go test ./internal/xds/translator`

Fixes envoyproxy#9355

Signed-off-by: Arko Dasgupta <[email protected]>

@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: a6a566a5f2

ℹ️ 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/lua.go Outdated
Comment on lines +123 to +124
if err := enableFilterOnRoute(route, filterName, &routev3.FilterConfig{
Config: &anypb.Any{},

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge Preserve Lua filterContext when enabling routes

For Lua policies that set spec.lua[].filterContext, this now enables the disabled HCM Lua filter with a generic empty FilterConfig, so ep.FilterContext is never serialized into xDS. The API promises these values are available via request_handle:filterContext() (api/v1alpha1/lua_types.go:51-57), and the existing Lua e2e fixture depends on that header being produced. In that scenario, scripts will see an empty/nil context after this change and stop behaving as configured.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

this seems valid, can you verify again?

@arkodg
arkodg force-pushed the revert-lua-per-route-8355-8598 branch from a6a566a to c44e9ef Compare July 7, 2026 00:48
zhaohuabing
zhaohuabing previously approved these changes Jul 7, 2026

@zhaohuabing zhaohuabing left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM. Thanks!

The listener drain can be solved later using the Envoy filter_chain filter.

@codecov

codecov Bot commented Jul 7, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.00000% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.33%. Comparing base (30d456e) to head (b930e4b).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
internal/xds/translator/lua.go 70.00% 5 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9426      +/-   ##
==========================================
- Coverage   75.35%   75.33%   -0.02%     
==========================================
  Files         252      252              
  Lines       41475    41483       +8     
==========================================
- Hits        31254    31253       -1     
- Misses       8108     8115       +7     
- Partials     2113     2115       +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.

rudrakhp
rudrakhp previously approved these changes Jul 7, 2026
@sadovnikov

Copy link
Copy Markdown
Contributor

Thanks! Will this be added to v1.8.3?

@arkodg
arkodg dismissed stale reviews from rudrakhp and zhaohuabing via 6f7e7b6 July 8, 2026 05:22
@zirain
zirain force-pushed the revert-lua-per-route-8355-8598 branch from 6f7e7b6 to 104d2f8 Compare July 8, 2026 14:13
@zirain

zirain commented Jul 8, 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: 104d2f8505

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

Comment thread internal/xds/translator/lua.go Resolved
Remove unrelated Gateway API status-merge and redirect regression files that were accidentally included with the filterContext follow-up.

Add a breaking-change fragment documenting the listener-level Lua source layout and filter-key migration for EnvoyPatchPolicy and extension consumers.

Test: make test
Signed-off-by: Arko Dasgupta <[email protected]>
@arkodg
arkodg force-pushed the revert-lua-per-route-8355-8598 branch from 104d2f8 to b930e4b Compare July 9, 2026 16:49
@arkodg
arkodg requested review from rudrakhp, zhaohuabing and zirain July 9, 2026 17:01
@zhaohuabing

Copy link
Copy Markdown
Member

/retest

@arkodg

arkodg commented Jul 11, 2026

Copy link
Copy Markdown
Contributor Author

Thanks! Will this be added to v1.8.3?

yeah thats the plan

@arkodg
arkodg merged commit 76bd888 into envoyproxy:main Jul 11, 2026
59 of 65 checks passed
jukie pushed a commit to jukie/gateway that referenced this pull request Jul 22, 2026
* Revert "[xds] stabilize listener-level Lua XDS filters to avoid listener drain (envoyproxy#8598)"

This reverts commit 80b2762.

Why:
- Back out the LuaPerRoute stabilization layer together with envoyproxy#8355 while
  investigating the Gateway-scoped Lua memory regression from envoyproxy#9355.
- envoyproxy#8598 only stabilizes per-route Lua HCM slot names; it still leaves Lua
  source materialized per route, so it is not sufficient for the memory issue.

Test plan:
- `go test ./internal/xds/translator`

Signed-off-by: Arko Dasgupta <[email protected]>

* Revert "refactor/perf: use LuaPerRoute instead of FilterConfig (envoyproxy#8355)"

This reverts commit f31ac4e.

Why:
- envoyproxy#8355 materialized Gateway-targeted Lua as per-route LuaPerRoute source code.
- With large route tables, identical Gateway-scoped scripts are duplicated across
  route entries and worker Lua runtime state, matching the memory regression
  reported in envoyproxy#9355.
- Restoring listener-level Lua source avoids scaling the Gateway-scoped script
  with route count.

Test plan:
- `go test ./internal/xds/translator`

Fixes envoyproxy#9355

Signed-off-by: Arko Dasgupta <[email protected]>

* add filterContext in per route level

Signed-off-by: Arko Dasgupta <[email protected]>

* [xds] scope Lua revert to translator changes

Remove unrelated Gateway API status-merge and redirect regression files that were accidentally included with the filterContext follow-up.

Add a breaking-change fragment documenting the listener-level Lua source layout and filter-key migration for EnvoyPatchPolicy and extension consumers.

Test: make test
Signed-off-by: Arko Dasgupta <[email protected]>

---------

Signed-off-by: Arko Dasgupta <[email protected]>
(cherry picked from commit 76bd888)
Signed-off-by: jukie <[email protected]>
jukie added a commit that referenced this pull request Jul 22, 2026
* detect ipv6 literal hosts in url2cluster and token endpoint check (#9165)

* detect ipv6 literal hosts in url2cluster and token endpoint check

Signed-off-by: dxbjavid <[email protected]>

* add release note for ipv6 literal endpoint fix

Signed-off-by: dxbjavid <[email protected]>

---------

Signed-off-by: dxbjavid <[email protected]>
Signed-off-by: zirain <[email protected]>
Signed-off-by: Javid Khan <[email protected]>
Co-authored-by: zirain <[email protected]>
(cherry picked from commit 30d456e)
Signed-off-by: jukie <[email protected]>

* Revert LuaPerRoute source materialization for Lua (#9426)

* Revert "[xds] stabilize listener-level Lua XDS filters to avoid listener drain (#8598)"

This reverts commit 80b2762.

Why:
- Back out the LuaPerRoute stabilization layer together with #8355 while
  investigating the Gateway-scoped Lua memory regression from #9355.
- #8598 only stabilizes per-route Lua HCM slot names; it still leaves Lua
  source materialized per route, so it is not sufficient for the memory issue.

Test plan:
- `go test ./internal/xds/translator`

Signed-off-by: Arko Dasgupta <[email protected]>

* Revert "refactor/perf: use LuaPerRoute instead of FilterConfig (#8355)"

This reverts commit f31ac4e.

Why:
- #8355 materialized Gateway-targeted Lua as per-route LuaPerRoute source code.
- With large route tables, identical Gateway-scoped scripts are duplicated across
  route entries and worker Lua runtime state, matching the memory regression
  reported in #9355.
- Restoring listener-level Lua source avoids scaling the Gateway-scoped script
  with route count.

Test plan:
- `go test ./internal/xds/translator`

Fixes #9355

Signed-off-by: Arko Dasgupta <[email protected]>

* add filterContext in per route level

Signed-off-by: Arko Dasgupta <[email protected]>

* [xds] scope Lua revert to translator changes

Remove unrelated Gateway API status-merge and redirect regression files that were accidentally included with the filterContext follow-up.

Add a breaking-change fragment documenting the listener-level Lua source layout and filter-key migration for EnvoyPatchPolicy and extension consumers.

Test: make test
Signed-off-by: Arko Dasgupta <[email protected]>

---------

Signed-off-by: Arko Dasgupta <[email protected]>
(cherry picked from commit 76bd888)
Signed-off-by: jukie <[email protected]>

* fix: default backend TLS max version to 1.3 (#9412)

Backend (upstream) TLS connections were silently capped at TLS 1.2.
Apply the defaults (min 1.2, max 1.3) in applyBackendTLSSetting when not configured.

Fixes #9395

Signed-off-by: vishwas-bm <[email protected]>
(cherry picked from commit 581a9c5)
Signed-off-by: jukie <[email protected]>

* fix: add default retry policy for Envoy wasm module fetch (#9462)

add default retry policy for Envoy wasm module fetch

Signed-off-by: jukie <[email protected]>
(cherry picked from commit 3e18557)
Signed-off-by: jukie <[email protected]>

* fix/refactor: deep copy status in translator for all resources (#9458)

Signed-off-by: Rudrakh Panigrahi <[email protected]>
Co-authored-by: zirain <[email protected]>
(cherry picked from commit e51b417)
Signed-off-by: jukie <[email protected]>

* fix(logs): restore ISO 8601 timestamp format (#9493)

* fix(logs): restore ISO 8601 timestamp format

Signed-off-by: Florian Wiegand <[email protected]>

* fix(logs): add release note for ISO 8601 timestamp fix

Signed-off-by: Florian Wiegand <[email protected]>

---------

Signed-off-by: Florian Wiegand <[email protected]>
(cherry picked from commit 2621405)
Signed-off-by: jukie <[email protected]>

* fix: unreferenced Secret events trigger reconciliation when HTTPRouteFilter CRD exists (#9488)

* fix: unreferenced Secret events trigger reconciliation when HTTPRouteFilter CRD exists

isHTTPRouteFilterReferencingSecret returned true on both branches, so with
the HTTPRouteFilter CRD installed (the default), every Secret write in the
cluster passed validateSecretForReconcile and enqueued a full reconcile.
Any high-frequency Secret writer (secret sync controllers, cert rotation)
drives the controller to reconcile continuously.

Return false when no HTTPRouteFilter references the Secret, matching the
other is*ReferencingSecret helpers. Enable hrfCRDExists in the predicate
test so the existing unreferenced-Secret case guards this path, and add
positive/negative cases for HTTPRouteFilter credential injection refs.

Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: James Hong <[email protected]>
(cherry picked from commit 4d7686c)
Signed-off-by: jukie <[email protected]>

---------

Signed-off-by: dxbjavid <[email protected]>
Signed-off-by: zirain <[email protected]>
Signed-off-by: Javid Khan <[email protected]>
Signed-off-by: jukie <[email protected]>
Signed-off-by: Arko Dasgupta <[email protected]>
Signed-off-by: vishwas-bm <[email protected]>
Signed-off-by: Rudrakh Panigrahi <[email protected]>
Signed-off-by: Florian Wiegand <[email protected]>
Signed-off-by: James Hong <[email protected]>
Co-authored-by: Javid Khan <[email protected]>
Co-authored-by: zirain <[email protected]>
Co-authored-by: Arko Dasgupta <[email protected]>
Co-authored-by: vishwas-bm <[email protected]>
Co-authored-by: Rudrakh Panigrahi <[email protected]>
Co-authored-by: Florian Wiegand <[email protected]>
Co-authored-by: James Hong <[email protected]>
Co-authored-by: Claude Fable 5 <[email protected]>
@zhaohuabing

zhaohuabing commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

It seems ECDS can be used to pull lua script out of band to avoid listener drain.

- name: envoy.filters.http.lua/0
  disabled: true
  configDiscovery:
    configSource: {ads: {}}
    typeUrls: [type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua]
    defaultConfig:
      '@type': type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua
    applyDefaultConfigWithoutWarming: true

https://www.envoyproxy.io/docs/envoy/latest/configuration/overview/extension
https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/core/v3/config_source.proto#envoy-v3-api-msg-config-core-v3-extensionconfigsource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Gateway-targeted EnvoyExtensionPolicy Lua is materialized per route (LuaPerRoute) since v1.7.2: proxy memory scales with route count x worker threads

5 participants