Skip to content

fix: handle mixed endpoints in DNS clusters - #1849

Open
avinxshKD wants to merge 1 commit into
kmesh-net:mainfrom
avinxshKD:fix/kernel-native-dns-mixed-endpoints
Open

fix: handle mixed endpoints in DNS clusters#1849
avinxshKD wants to merge 1 commit into
kmesh-net:mainfrom
avinxshKD:fix/kernel-native-dns-mixed-endpoints

Conversation

@avinxshKD

Copy link
Copy Markdown
Contributor

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.

Fix kernel-native DNS cluster resolution for localities containing mixed hostname and IP endpoints.

Signed-off-by: Avinash Kumar Deepak <avinash8655279@gmail.com>
Copilot AI review requested due to automatic review settings August 2, 2026 16:44
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@kmesh-bot kmesh-bot added the kind/bug Something isn't working label Aug 2, 2026
@kmesh-bot
kmesh-bot requested review from hzxuzhonghu and nlgwcy August 2, 2026 16:44
@kmesh-bot

Copy link
Copy Markdown
Collaborator

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign hzxuzhonghu for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Copilot AI left a comment

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.

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 overwriteDnsCluster to rebuild each locality’s LbEndpoints by 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

codecov Bot commented Aug 2, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 88.88889% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 39.50%. Comparing base (63e0279) to head (ec11cbe).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/controller/ads/dns.go 88.88% 1 Missing ⚠️
Files with missing lines Coverage Δ
pkg/controller/ads/dns.go 70.05% <88.88%> (-0.95%) ⬇️

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update c88ef30...ec11cbe. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/bug Something isn't working size/M

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kernel-native DNS resolver panics on mixed hostname/IP endpoints

3 participants