Bracket IPv6 addresses in control-plane join URLs - #1577
Closed
magic-peach wants to merge 1 commit into
Closed
Conversation
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>
Contributor
|
Please, check the #1566 comments |
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. |
Contributor
|
@magic-peach If you still open for contribution, feel free to implement the unified approach straight away |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:9443instead ofhttps://[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