Skip to content

fix: support ipv6 pod backend URLs#1071

Merged
volcano-sh-bot merged 1 commit into
volcano-sh:mainfrom
pm-ju:fix-router-backend-ipv6-pod-urls
May 19, 2026
Merged

fix: support ipv6 pod backend URLs#1071
volcano-sh-bot merged 1 commit into
volcano-sh:mainfrom
pm-ju:fix-router-backend-ipv6-pod-urls

Conversation

@pm-ju
Copy link
Copy Markdown
Contributor

@pm-ju pm-ju commented May 15, 2026

/kind bug

What this PR does / why we need it:

vLLM and SGLang backend code built pod URLs with fmt.Sprintf("http://%s:%d/...", podIP, port). This works for IPv4, but creates invalid URLs for IPv6 pod IPs because IPv6 literals must be bracketed.

This PR adds a shared PodEndpointURL helper using net.JoinHostPort and uses it for:

  • vLLM metrics endpoint
  • vLLM model list endpoint
  • SGLang metrics endpoint

This keeps router backend metric/model fetching working in IPv6 or dual-stack Kubernetes clusters.

Which issue(s) this PR fixes:

None

Verification:

git diff --check
image

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a PodEndpointURL utility function to standardize URL construction for pod endpoints, specifically improving support for IPv6 addresses. The sglang and vllm backends were updated to use this utility, and unit tests were added to cover various IP formats. Feedback suggests adding documentation for the exported function and ensuring the path parameter is correctly handled to prevent malformed URLs.

return httpClient
}

func PodEndpointURL(podIP string, port uint32, path string) string {
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.

medium

Exported functions should have a doc comment explaining their purpose and behavior. This is a standard Go practice to maintain code readability and documentation quality, especially for shared utility functions.

Suggested change
func PodEndpointURL(podIP string, port uint32, path string) string {
// PodEndpointURL constructs a URL for a pod endpoint, correctly handling IPv6 addresses by wrapping them in brackets.
func PodEndpointURL(podIP string, port uint32, path string) string {

}

func PodEndpointURL(podIP string, port uint32, path string) string {
return "http://" + net.JoinHostPort(podIP, strconv.FormatUint(uint64(port), 10)) + path
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.

medium

The current implementation assumes that the path argument always starts with a leading slash. If it doesn't, the resulting URL will be malformed (e.g., http://host:portpath). It is safer to ensure the slash is present or use a more robust URL construction method.

	if len(path) > 0 && path[0] != '/' {
		path = "/" + path
	}
	return "http://" + net.JoinHostPort(podIP, strconv.FormatUint(uint64(port), 10)) + path

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

Can you please also update the router.go?

Copilot AI review requested due to automatic review settings May 18, 2026 11:36
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 7 out of 7 changed files in this pull request and generated no new comments.

@pm-ju
Copy link
Copy Markdown
Contributor Author

pm-ju commented May 18, 2026

Can you please also update the router.go?

I have updated it and that do-not-merge label was because I had some merge conflicts which I have resolved.

Comment thread pkg/kthena-router/router/router.go Outdated
return resp, nil
}

func podHostPort(podIP string, port int32) string {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I am thinking this function is redudant

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fair point, it was only wrapping net.JoinHostPort. I removed the helper and now use net.JoinHostPort directly at the call sites.

I’ll also squash the commits before the next push.

@hzxuzhonghu
Copy link
Copy Markdown
Member

@pm-ju You can and should squash the commits

Copilot AI review requested due to automatic review settings May 19, 2026 10:26
@pm-ju pm-ju force-pushed the fix-router-backend-ipv6-pod-urls branch from e5e5006 to 2965d39 Compare May 19, 2026 10:26
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 6 out of 7 changed files in this pull request and generated no new comments.

Signed-off-by: pm-ju <pmdevops29@gmail.com>
@pm-ju pm-ju force-pushed the fix-router-backend-ipv6-pod-urls branch from 2965d39 to dc877ce Compare May 19, 2026 10:44
Copy link
Copy Markdown
Member

@hzxuzhonghu hzxuzhonghu left a comment

Choose a reason for hiding this comment

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

/lgtm

@volcano-sh-bot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hzxuzhonghu

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

The pull request process is described 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

@volcano-sh-bot volcano-sh-bot merged commit 06377ca into volcano-sh:main May 19, 2026
18 checks passed
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.

4 participants