Skip to content

fix: HealthCheck should respect endpoint hostname#8854

Draft
zirain wants to merge 10 commits intoenvoyproxy:mainfrom
zirain:host-rewrite-healthcheck
Draft

fix: HealthCheck should respect endpoint hostname#8854
zirain wants to merge 10 commits intoenvoyproxy:mainfrom
zirain:host-rewrite-healthcheck

Conversation

@zirain
Copy link
Copy Markdown
Member

@zirain zirain commented Apr 25, 2026

fix: #8848

@netlify
Copy link
Copy Markdown

netlify Bot commented Apr 25, 2026

Deploy Preview for cerulean-figolla-1f9435 ready!

Name Link
🔨 Latest commit 4644cd8
🔍 Latest deploy log https://app.netlify.com/projects/cerulean-figolla-1f9435/deploys/69fad47fe8f97c0008f463df
😎 Deploy Preview https://deploy-preview-8854--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
Copy link
Copy Markdown

codecov Bot commented Apr 25, 2026

Codecov Report

❌ Patch coverage is 92.00000% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 74.72%. Comparing base (69b1dde) to head (4644cd8).

Files with missing lines Patch % Lines
internal/xds/translator/cluster.go 92.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8854      +/-   ##
==========================================
- Coverage   74.73%   74.72%   -0.02%     
==========================================
  Files         251      251              
  Lines       40360    40379      +19     
==========================================
+ Hits        30165    30175      +10     
- Misses       8130     8135       +5     
- Partials     2065     2069       +4     

☔ View full report in Codecov by Sentry.
📢 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.

albsga4 added a commit to albsga4/gateway that referenced this pull request Apr 25, 2026
…ostFrom test

- Remove auto-derive of DestinationEndpoint.Hostname from FQDN in
  route.go (changed IR output for all FQDN backends unnecessarily)
- Include health check testdata from envoyproxy#8854 (by @zirain)
- Add backendtrafficpolicy-with-healthcheck-auto-host-rewrite test
  exercising HostFrom=Endpoint with hostname.type: Backend

Signed-off-by: asalvador <asalvador@newrelic.com>
@zirain zirain force-pushed the host-rewrite-healthcheck branch 2 times, most recently from f31f65c to f2d4d6a Compare April 25, 2026 00:43
albsga4 added a commit to albsga4/gateway that referenced this pull request Apr 25, 2026
Signed-off-by: asalvador <asalvador@newrelic.com>
@zirain zirain marked this pull request as ready for review April 25, 2026 09:17
@zirain zirain requested a review from a team as a code owner April 25, 2026 09:17
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

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: f2d4d6a8a3

ℹ️ 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/gatewayapi/testdata/backendtrafficpolicy-with-healthcheck.out.yaml Outdated
@zirain zirain changed the title chore: update health check testdata fix: HealthCheck should respect URLWrite host configuration. Apr 25, 2026
Copy link
Copy Markdown

@albsga4 albsga4 left a comment

Choose a reason for hiding this comment

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

Nice approach — passing the URLRewrite directly to the xDS translator is cleaner than adding a new IR field. Tested locally with a gatewayapi golden test for hostname.type: Backend (auto-host-rewrite via HTTPRouteFilter ExtensionRef) and it works correctly on your branch.

The unit test in cluster_test.go covers the xDS level well. One suggestion: a gatewayapi integration test would also cover the full flow (HTTPRouteFilter → IR → xDS). Feel free to grab the test input from my PR: backendtrafficpolicy-with-healthcheck-auto-host-rewrite.in.yaml

It has two routes:

  1. Auto-host-rewrite + no explicit http.hostname → health check uses Backend.endpoint.hostname
  2. Auto-host-rewrite + explicit http.hostname → explicit value wins

I'll close #8851 in favor of this PR. Thanks for taking this on!

@zirain
Copy link
Copy Markdown
Member Author

zirain commented Apr 25, 2026

@copilot resolve the merge conflicts in this pull request

@arkodg
Copy link
Copy Markdown
Contributor

arkodg commented Apr 26, 2026

imo irrespective of URL rewrite being enabled or not, the endpoint hostname should be used if healthCheck host is unset

@zirain
Copy link
Copy Markdown
Member Author

zirain commented Apr 26, 2026

imo irrespective of URL rewrite being enabled or not, the endpoint hostname should be used if healthCheck host is unset

I do believe we should use Endpoint hostname by default if we don't care aboud backward compatibility.

Copy link
Copy Markdown

@albsga4 albsga4 left a comment

Choose a reason for hiding this comment

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

Tested hostname.type: Backend with two FQDN backends without the explicit hostname field on the Backend endpoint. Routing works (Envoy uses the FQDN address for STRICT_DNS auto_host_rewrite), but health checks get nothing because ep.Hostname is nil.

Suggested a fallback to ep.Host (the FQDN address) so users don't need to duplicate the FQDN.

Comment thread internal/xds/translator/cluster.go
Copy link
Copy Markdown

@albsga4 albsga4 left a comment

Choose a reason for hiding this comment

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

Requesting changes: hostname.type: Backend with FQDN backends that don't set the explicit hostname field results in no per-endpoint health check hostname. See suggestion for fallback to ep.Host.

@zirain zirain force-pushed the host-rewrite-healthcheck branch from b90975e to 9f2c250 Compare April 28, 2026 02:46
@zirain zirain requested a review from albsga4 April 28, 2026 06:23
Copy link
Copy Markdown

@albsga4 albsga4 left a comment

Choose a reason for hiding this comment

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

The hostname field on BackendEndpoint was added in #6503 / #6280 specifically for IP-based backends where there is no DNS name for auto_host_rewrite to use. For FQDN backends, the FQDN address IS the hostname — forcing users to duplicate it doesn't add value.

Verified on a live cluster: auto_host_rewrite on STRICT_DNS correctly rewrites Host to the FQDN address for each endpoint, even without the explicit hostname field. But health checks get nothing because ep.Hostname is nil.

Comment thread internal/xds/translator/cluster.go
Hostname: ptr.Deref(irEp.Hostname, ""),
Address: buildAddress(irEp),
HealthCheckConfig: buildHealthCheckConfig(hc, irEp),
HealthCheckConfig: buildHealthCheckConfig(hc, rewrite, irEp),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

imo we shouldnt be using route rewrite info which is for user requests for health check request semantics

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Correct me if I'm wrong, when you rewrited the URL that mostly because the upstream may only accept the rewrited host(no matter it's from per-route or per-backend).

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Rewriting applies to user requests initiated by downstream
Health check requests are initiated by envoy with specific info of backend ( host, dns/ip)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Removed it now, we could add it back if needed in the future.

@zirain zirain force-pushed the host-rewrite-healthcheck branch from 06d6519 to dbf8f63 Compare May 1, 2026 13:54
@zirain zirain requested review from albsga4 and arkodg May 3, 2026 15:24
- matches:
- path:
value: "/v6-rewrite"
# Hostname rewrite filter applied, should use example2.com when doing health check.
Copy link
Copy Markdown
Contributor

@arkodg arkodg May 3, 2026

Choose a reason for hiding this comment

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

can the title & examples be updated to not rely on URLRewrite for heathcheck semantics

Comment thread internal/xds/translator/cluster.go
@zhaohuabing zhaohuabing requested review from arkodg and zhaohuabing May 6, 2026 03:42
@zirain zirain changed the title fix: HealthCheck should respect URLWrite host configuration. fix: HealthCheck should respect URLWrite host configuration in backend refs May 6, 2026
@zirain zirain changed the title fix: HealthCheck should respect URLWrite host configuration in backend refs fix: HealthCheck should respect auto-host-rewrite May 6, 2026
zirain and others added 9 commits May 6, 2026 11:47
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Co-authored-by: albsga4 <asalvador@newrelic.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain force-pushed the host-rewrite-healthcheck branch from aa81ed1 to 48ff586 Compare May 6, 2026 03:56
@zirain zirain changed the title fix: HealthCheck should respect auto-host-rewrite fix: HealthCheck should respect endpoint hostname May 6, 2026
Signed-off-by: zirain <zirain2009@gmail.com>
@zirain zirain removed this from the v1.8.0 Release milestone May 7, 2026
@zirain zirain marked this pull request as draft May 7, 2026 12:56
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.

Health check Host header should use backend endpoint FQDN when auto-host-rewrite is configured

5 participants