Skip to content

fix: unreferenced Secret events trigger reconciliation when HTTPRouteFilter CRD exists - #9488

Merged
arkodg merged 4 commits into
envoyproxy:mainfrom
Greyeye:fix/secret-predicate-httproutefilter
Jul 16, 2026
Merged

arkodg merged 4 commits into
envoyproxy:mainfrom
Greyeye:fix/secret-predicate-httproutefilter

Conversation

@Greyeye

@Greyeye Greyeye commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

isHTTPRouteFilterReferencingSecret in internal/provider/kubernetes/predicates.go
returns true on both branches — the fall-through after an empty index lookup
reads return true where every sibling is*ReferencingSecret helper returns
false:

if len(routeFilterList.Items) > 0 {
    return true
}

return true // should be: return false

The helper is part of the validateSecretForReconcile predicate chain on the
cluster-wide Secret watch, and it is gated only on the HTTPRouteFilter CRD
existing
(r.hrfCRDExists) — not on any HTTPRouteFilter instances or Secret
references existing. Since the CRD ships with the default install, the effective
behavior on virtually every Envoy Gateway deployment is: every Secret
create/update/delete event in the entire cluster passes the predicate and
enqueues a full reconcile
(complete resource-snapshot rebuild, full
gateway-api translation, xDS regeneration).

Any high-frequency Secret writer turns this into a sustained reconcile storm.
We hit this in production: a secret-sync controller rewriting a CA Secret
across ~90 namespaces every ~30s drove the controller to a sustained 2–3 full
reconciles per second indefinitely, on a cluster whose Gateway API config
rarely changes. Verified 1:1: 94 Secret watch events and a reconcile-counter
delta of exactly 94 in the same 30-second window; stopping the Secret writer
froze the counter completely. Common writers like external-secrets-operator
refresh loops or cert-manager renewal waves reproduce the same behavior.

The fix is the one-line return false on the fall-through, matching the other
is*ReferencingSecret helpers.

Test changes (predicates_test.go):

  • Set hrfCRDExists: true on the test reconciler and register
    secretHTTPRouteFilterIndex on the fake client. The existing
    "secret is not referenced by any EG CRs" case previously skipped the buggy
    branch entirely (the flag was unset), which is how this escaped; it now
    guards this path and fails against the unfixed code.
  • Add a positive case: HTTPRouteFilter credential-injection valueRef to the
    Secret → reconcile.
  • Add a negative case: HTTPRouteFilter exists but references a different
    Secret → no reconcile.

The bug was introduced with the direct response feature (#4508) and is present
in all releases since; this is a good candidate for cherry-picks to the active
release branches (verified present in v1.8.1/v1.8.2).

Which issue(s) this PR fixes:

Fixes #9486

(Issue: Secret watch predicate isHTTPRouteFilterReferencingSecret unconditionally returns true — every Secret write in the cluster triggers a full reconcile)


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: N/A — no changes under /api.
  • Required checks pass: make generate gen-check, make lint, and the unit-test/coverage build pass.
    (Verified locally: go test ./internal/provider/kubernetes/ → ok, TestValidateSecretForReconcile fails against the unfixed code, and make gen-check passes with a clean worktree. make lint still to run if not already done.)
  • Tests added/updated: Regression coverage added — existing unreferenced-Secret case now exercises the HRF branch; positive + negative HTTPRouteFilter cases added.
  • Docs: N/A — no user-facing behavior change beyond removing unintended reconciles.
  • Release notes: Added release-notes/current/bug_fixes/9486-secret-predicate-httproutefilter.md (named after issue Secret watch predicate isHTTPRouteFilterReferencingSecret unconditionally returns true — every Secret write in the cluster triggers a full reconcile #9486, per release-notes/current/README.md which allows PR or issue number; commit 4f205d0d6).
  • Generated files committed: N/A — no API/helm/module changes (run make gen-check anyway per the checks item above).
  • Scope & compatibility: Two files, one behavioral line + tests; no unrelated changes; strictly removes unintended reconciles, no compatibility impact.
  • Codex review: Request on GitHub after opening the PR.
  • Copilot review: Request on GitHub after opening the PR.

Greyeye and others added 2 commits July 14, 2026 12:22
…Filter 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]>
Co-Authored-By: Claude Fable 5 <[email protected]>
Signed-off-by: James Hong <[email protected]>
@Greyeye
Greyeye requested a review from a team as a code owner July 14, 2026 02:42
@netlify

netlify Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

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

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

@codecov

codecov Bot commented Jul 15, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 75.54%. Comparing base (b68043e) to head (491ffb8).
⚠️ Report is 4 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #9488      +/-   ##
==========================================
+ Coverage   75.47%   75.54%   +0.06%     
==========================================
  Files         252      252              
  Lines       41662    41662              
==========================================
+ Hits        31445    31472      +27     
+ Misses       8087     8061      -26     
+ Partials     2130     2129       -1     

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

@kkk777-7

Copy link
Copy Markdown
Member

LGTM, thanks!

@arkodg
arkodg merged commit 4d7686c into envoyproxy:main Jul 16, 2026
36 of 39 checks passed
jukie pushed a commit to jukie/gateway that referenced this pull request Jul 22, 2026
…Filter CRD exists (envoyproxy#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]>
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]>
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.

Secret watch predicate isHTTPRouteFilterReferencingSecret unconditionally returns true — every Secret write in the cluster triggers a full reconcile

6 participants