fix: handle mixed endpoints in DNS clusters - #1849
Conversation
Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Pull request overview
Fixes a panic and incorrect DNS endpoint rewriting in kernel-native ADS DNS handling when clusters contain localities with mixed hostname and IP endpoints. The updated overwriteDnsCluster logic now expands each hostname endpoint independently while preserving existing IP endpoints and maintaining per-locality endpoint ordering.
Changes:
- Reworked
overwriteDnsClusterto rebuild each locality’sLbEndpointsby expanding each hostname into its resolved IP endpoints and preserving IP/non-socket endpoints. - Removed debug/unused logic (
fmt.Printf,slices.Replace) tied to the prior “replace last hostname” approach. - Added a regression test covering mixed hostname/IP endpoints across multiple localities and multiple hostnames in-order.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| pkg/controller/ads/dns.go | Rebuilds locality endpoints to safely expand hostnames and preserve IP endpoints without panics. |
| pkg/controller/ads/dns_test.go | Adds regression coverage for mixed endpoints and multiple hostnames across localities. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
... and 2 files with indirect coverage changes Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
What type of PR is this?
/kind bug
What this PR does / why we need it:
Fixes DNS cluster rewriting for mixed hostname and IP endpoints. The old code replaced only the last hostname and panicked for localities containing only IP endpoints.
The new logic expands each hostname independently while preserving existing IP endpoints and locality order. Added regression coverage for mixed endpoints and multiple hostnames.
Which issue(s) this PR fixes:
Fixes #1848
Special notes for your reviewer:
The change is limited to
overwriteDnsCluster. Existing IPv4-only behavior is preserved.Does this PR introduce a user-facing change?:
Yes.