Skip to content

Bracket IPv6 addresses in control-plane join URLs - #1577

Closed
magic-peach wants to merge 1 commit into
k0sproject:mainfrom
magic-peach:fix/1565-bracket-ipv6-join-url
Closed

Bracket IPv6 addresses in control-plane join URLs#1577
magic-peach wants to merge 1 commit into
k0sproject:mainfrom
magic-peach:fix/1565-bracket-ipv6-join-url

Conversation

@magic-peach

Copy link
Copy Markdown

Join URLs were built with raw fmt.Sprintf("https://%s:%s", host, port), which produces an invalid URL for IPv6 addresses (e.g. https://2001:db8::1:9443 instead of https://[2001:db8::1]:9443).

Fixed at all 4 locations named in the issue by building the host:port part with net.JoinHostPort, which brackets IPv6 literals correctly and is a no-op for hostnames/IPv4. Extracted two small helpers to make the fix testable and added unit tests for the hostname/IPv4/IPv6 cases.

Fixes #1565

worker_bootstrap_controller.go and controlplane_bootstrap_controller.go
built join/detection URLs with plain fmt.Sprintf("https://%s:%d", ...),
which produces an invalid URL for an IPv6 host
(https://2001:db8::1:443 instead of https://[2001:db8::1]:443).
Workers behind an IPv6-only control-plane LoadBalancer address failed
to bootstrap as a result.

Use net.JoinHostPort, which brackets IPv6 literals and is a no-op for
IPv4/hostnames, via two small local helpers (controlPlaneJoinURL,
joinHostPortURL) that also make the fix unit-testable.

Fixes k0sproject#1565

Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
@magic-peach
magic-peach requested a review from a team as a code owner August 31, 2026 08:56
@makhov

makhov commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Please, check the #1566 comments

@magic-peach

Copy link
Copy Markdown
Author

Thanks for pointing me to #1566 I hadn't seen it, this duplicates that work. @pujitha24's PR already covers these call sites plus the jointoken/kubeconfig paths. Closing this in favor of #1566.
@makhov if a unified URL-building helper across the codebase is still the direction, happy to help scope or build it once #1566 settles ,didn't want to add a third overlapping attempt in the meantime.

@makhov

makhov commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

@magic-peach If you still open for contribution, feel free to implement the unified approach straight away

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.

IPv6 control-plane endpoint: join URL is not bracketed

2 participants