Skip to content

test(e2e): apply gRPC health check routes once the backend serves - #10405

Merged
zirain merged 2 commits into
envoyproxy:mainfrom
nobbs:test/grpc-health-check-flake
Oct 31, 2026
Merged

zirain merged 2 commits into
envoyproxy:mainfrom
nobbs:test/grpc-health-check-flake

Conversation

@nobbs

@nobbs nobbs commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

What this PR does / why we need it:

TestE2E/BackendHealthCheckActiveGRPC/explicit_hostname_is_used_as_authority, added in #10093, is flaky. It failed six times since 19 Oct: four times on #10093, once on its merge commit to main, and once on #10402. Each time, the health check success counter of the first cluster the test checks stayed at 0 for the whole 30s wait.

The test applied grpc-health-backend together with its routes and BackendTrafficPolicies:

apply backend, GRPCRoutes, BTPs
  pod gets an IP, not Ready yet
    EG publishes the endpoint as DRAINING (#7253)
      Envoy gets the clusters and health checks the host at once
        server not listening yet: network failure, host /failed_active_hc
  pod turns Ready: only the EDS health status changes, no new check
  next check after no_traffic_interval (60s), past the test's 30s

This PR applies the health checked resources only once the backend serves:

 Manifests: backend-health-check-active-grpc.yaml    # now Deployment + Service only
+  readinessProbe: grpc, port 9000                   # Ready means serving
 Test:
+  WaitForPods(app=grpc-health-backend, Ready)
+  MustApplyWithCleanup(backend-health-check-active-grpc-hc.yaml)   # BTPs, then GRPCRoutes
   GatewayAndRoutesMustBeAccepted, BackendTrafficPolicyMustBeAccepted
-  WaitForPods(app=grpc-health-backend, Ready)
   await health check stats, then gRPC checks through the Gateway

The BTPs come before the routes because a route processed before its policy yields a cluster without the health check. In my reproduction, the update that then added the health check waited for EDS until initial_fetch_timeout (15s), half the test's budget. Waiting first and applying afterwards follows oidc.go, which applies its SecurityPolicy once Keycloak is up.

Evidence, from a kind cluster on main (4e77313) that applies the manifests in a loop and reads Envoy's admin API every 0.1s. An iteration fails when the explicit-hostname cluster has no health check success within 30s of the backend turning Ready. A 10m CPU limit on the backend slows its startup to make the race likely:

  • Before (main's manifest, CPU limit): 3 of 3 fail. The explicit-hostname cluster's first check is a network_failure, and its attempt stays at 1.
  • After (this PR's order): 5 of 5 pass with the CPU limit, 3 of 3 without. The success counts within 0.5s.
  • Without traffic, the second health check came after 61s, although the BTP sets interval: 5s.

Not covered locally: the gRPC requests through the Gateway, since the macOS host can't reach the Gateway's address. CI runs them.

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

Two observations outside this test: EG doesn't set no_traffic_interval, so a cluster without traffic recovers from a failed first check only after 60s, whatever interval the BTP sets. And adding a health check to an existing cluster took 15s to apply in my reproduction, waiting for EDS.

Which issue(s) this PR fixes:

No issue filed. The flake came in with #10093.


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 e2e test files, 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.

@nobbs
nobbs requested a review from a team as a code owner October 26, 2026 12:07
@netlify

netlify Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 78ce45f
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/6ae43f3c55280b22d7bf736f
😎 Deploy Preview https://deploy-preview-10405--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-30T06:58:45.461945Z 78ce45f New commits
ℹ️ 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.18%. Comparing base (b02cef4) to head (78ce45f).

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #10405      +/-   ##
==========================================
- Coverage   82.20%   82.18%   -0.02%     
==========================================
  Files         277      277              
  Lines       44014    44014              
==========================================
- Hits        36181    36173       -8     
- Misses       7832     7840       +8     
  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 Release milestone Oct 26, 2026
@nobbs
nobbs force-pushed the test/grpc-health-check-flake branch from 2903c77 to 599a952 Compare October 27, 2026 07:18
@nobbs
nobbs force-pushed the test/grpc-health-check-flake branch 2 times, most recently from 0e5e4e6 to 7fd319e Compare October 29, 2026 07:45
BackendHealthCheckActiveGRPC applied grpc-health-backend together with
its routes and BackendTrafficPolicies. EG publishes the endpoint of a pod
that is not Ready yet as draining, so Envoy received the health checked
clusters, and ran each first health check, while the gRPC server was
still starting. That check failed with a network error, and Envoy checks
a cluster that has seen no traffic again only after no_traffic_interval
(60s), past the 30s the test waits for a success.

Give the backend a gRPC readiness probe, wait for it, and only then apply
the policies and routes, policies first: a route processed before its
policy yields a cluster without the health check, and the update that
adds it waits for EDS until initial_fetch_timeout (15s).

Signed-off-by: Alexej Disterhoft <alexej@disterhoft.de>
@nobbs
nobbs force-pushed the test/grpc-health-check-flake branch from 7fd319e to ff9c694 Compare October 29, 2026 13:26
@kkk777-7

Copy link
Copy Markdown
Member

LGTM, thanks!

@kkk777-7

Copy link
Copy Markdown
Member

/retest

@zirain
zirain merged commit 79c6478 into envoyproxy:main Oct 31, 2026
74 of 76 checks passed
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.

3 participants