Skip to content

test(e2e): apply the health check event log BTP before its route - #10415

Merged
zhaohuabing merged 1 commit into
envoyproxy:mainfrom
nobbs:test/hc-event-log-flake
Oct 27, 2026
Merged

zhaohuabing merged 1 commit into
envoyproxy:mainfrom
nobbs:test/hc-event-log-flake

Conversation

@nobbs

@nobbs nobbs commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

TestE2E/BackendHealthCheckEventLog/health_check_events_appear_in_logs is flaky. On #10406, whose change is a provider unit test, it failed in 4 of the 7 e2e jobs that ran it: Loki showed no health check event for the whole 30s wait. The other 3 passed after 21.3s, 26.2s and 29.2s. On main's latest green run, 7 of the 8 e2e jobs needed 16–25s of the 30s.

The test applies the health checked route and its BTP from one file, route first:

create HTTPRoute, then BTP (~10ms apart)
  EG translates the route alone: Envoy gets its cluster without a health check
  EG translates route + BTP: Envoy gets an update that adds the health check
    Envoy warms the updated cluster until its endpoints arrive
      endpoints unchanged: no new ClusterLoadAssignment
    initial_fetch_timeout (15s): the update applies, the first check runs
  Envoy flushes stdout every 10s: the event reaches the log 0-10s later
  Loki ingests it

This PR applies the BTP first, so Envoy receives the cluster with its health check right away:

 testdata/backend-health-check-event-log-hc.yaml
+  BackendTrafficPolicy hc-event-log-btp
   HTTPRoute http-with-hc-event-log
-  BackendTrafficPolicy hc-event-log-btp

#10405 uses the same order for BackendHealthCheckActiveGRPC.

Evidence, from a kind cluster on main (bb149bb), running the e2e test 10 times per order, alternating:

  • Before (route first): Loki showed the first event 15.3–24.4s into the wait (median 17.0s). A probe reading Envoy's admin API saw the cluster's init_fetch_timeout counter go up in 5 of 5 runs, and the first check ran 14.8–14.9s after the route and BTP were created.
  • After (BTP first): 6.2–8.3s (median 7.2s). init_fetch_timeout did not change in 5 of 5 runs, and the first check ran as the route and BTP were created.
  • Across 118 events, Envoy wrote each event to stdout 0–9.9s (median 4.2s) after the check, its default file flush interval of 10s. That and Loki ingestion make up the rest of the wait.

Locally, all 20 of these runs passed the 30s budget. CI runners take longer, as the CI numbers above show, so there the route-first wait reaches the 30s.

Merge danger: a two-way door that changes only the order of one test manifest. The blast radius is this one e2e test.

Two observations outside this test:

  • As test(e2e): apply gRPC health check routes once the backend serves #10405 notes, a health check added to an existing route's cluster takes 15s to apply, waiting for EDS.
  • queryLoki counts matches over the last 10 minutes. When the test reruns within 10 minutes, events from the earlier run can age out during the wait, so the count can stay at the baseline although new events arrive. That failed 9 of my first 20 local runs, in both orders. The runs above narrow the window to the run, which gives the baseline of 0 that CI has: CI runs the test once per cluster.

Which issue(s) this PR fixes:

No issue filed. The test came in with #9651.


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. (N/A: no 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.) (make lint passes locally. The PR changes only an e2e testdata file, so gen-check and coverage are left to CI.)
  • Tests added/updated: New/changed code is covered by appropriate tests. N/A if this PR does not contain code changes. (The change is to the test itself.)
  • 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. (N/A: test-only.)
  • 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. (N/A: test-only.)
  • Generated files committed: Ran make gen-check and committed the result if API/helm charts/modules changed. (N/A: nothing generated 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.

BackendHealthCheckEventLog applied the HTTPRoute before the
BackendTrafficPolicy that adds its health check. EG translated the route
alone first, so Envoy received the route's cluster without a health check
and then an update that added one. Envoy warms the updated cluster until
it receives the cluster's endpoints, and as they had not changed, no new
ClusterLoadAssignment arrived: the update waited for EDS until
initial_fetch_timeout (15s), and only then did Envoy run the first check.
Envoy flushes the logged event to stdout every 10s, and Loki ingests it
after that, so on CI the test waited 16-29s for the first event, or failed
after its 30s.

Apply the BTP first, so that Envoy receives the cluster with its health
check right away and checks it as soon as the endpoints arrive.

Signed-off-by: Alexej Disterhoft <alexej@disterhoft.de>
@nobbs
nobbs requested a review from a team as a code owner October 26, 2026 21:36
@netlify

netlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

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

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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T21:39:03.629776Z 7a113d2 PR opened
ℹ️ 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" 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.

@codecov

codecov Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.13%. Comparing base (bb149bb) to head (7a113d2).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10415      +/-   ##
==========================================
+ Coverage   82.12%   82.13%   +0.01%     
==========================================
  Files         272      272              
  Lines       43156    43156              
==========================================
+ Hits        35440    35446       +6     
+ Misses       7715     7709       -6     
  Partials        1        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.

@zirain zirain added this to the v1.10.0-rc.1 Release milestone Oct 27, 2026
@zhaohuabing

zhaohuabing commented Oct 27, 2026 •

Copy link
Copy Markdown
Member

Does applying the BTP first actually close the race? The BTP and HTTPRoute arrive on separate informers, so the route can still be reconciled before the BTP is cached, and we're back to the 15s wait.

@zhaohuabing
zhaohuabing merged commit 2412be7 into envoyproxy:main Oct 27, 2026
101 of 106 checks passed
@nobbs

nobbs commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Does applying the BTP first actually close the race? The BTP and HTTPRoute arrive on separate informers, so the route can still be reconciled before the BTP is cached, and we're back to the 15s wait.

not 100%, but on my local tests reordering was good enough for the test to no longer fail. Proper fix would probably need changes similar to #10405

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.

3 participants