-
Notifications
You must be signed in to change notification settings - Fork 26
pkg/commands: normalizeEndpoint produces malformed URL for IPv6 endpoints #155
Copy link
Copy link
Closed
Labels
area/commandsIssues or PRs related to pkg/commands (CLI subcommands, flag parsing, root detection)Issues or PRs related to pkg/commands (CLI subcommands, flag parsing, root detection)kind/bugCategorizes issue or PR as related to a bugCategorizes issue or PR as related to a bugpriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next releaseMust be staffed and worked on either currently, or very soon, ideally in time for the next releasetriage/acceptedIndicates an issue is ready to be actively worked onIndicates an issue is ready to be actively worked on
Metadata
Metadata
Assignees
Labels
area/commandsIssues or PRs related to pkg/commands (CLI subcommands, flag parsing, root detection)Issues or PRs related to pkg/commands (CLI subcommands, flag parsing, root detection)kind/bugCategorizes issue or PR as related to a bugCategorizes issue or PR as related to a bugpriority/important-soonMust be staffed and worked on either currently, or very soon, ideally in time for the next releaseMust be staffed and worked on either currently, or very soon, ideally in time for the next releasetriage/acceptedIndicates an issue is ready to be actively worked onIndicates an issue is ready to be actively worked on
Summary
normalizeEndpoint()inpkg/commands/talosctl_wrapper.go:225-239produces a malformed URL for IPv6 inputs. Square brackets that delimit the host literal in URI authority syntax (RFC 3986, Gonet/url) are dropped, leaving an unparseablehttps://2001:db8::1:6443instead of the canonicalhttps://[2001:db8::1]:6443.Reproduction
url.Parse(got)rejects this URL: per Go'snet/urldocumentation, when the host is an IPv6 address it must be enclosed in square brackets. Any HTTP client or kubeconfig dialer that re-parses the value (e.g. throughclientcmd.LoadFromFilefollowed by a real connect attempt) will fail.Root cause
net.SplitHostPortstrips the brackets from[2001:db8::1]:6443, returninghost == "2001:db8::1". The finalfmt.Sprintfdoes NOT re-add them, producing the malformed string.Suggested fix
Use
net.JoinHostPortfor the assembly step — it adds brackets back automatically when the host contains a colon:This is the recommended pattern in
net/urldocumentation and works correctly for both IPv4 and IPv6 inputs.Notes
Discovered by CodeRabbit on PR #154 while reviewing the contract test that pinned the current (broken) output. The contract test on
test/chart-contractkeeps the broken case with a FIXME pointing at this issue, so the test can be tightened once the fix lands.Impact
updateKubeconfigServer()callsnormalizeEndpoint()to rewrite theserver:field of a managed kubeconfig. An operator running a single-node Talos on an IPv6 cluster endpoint would end up with a kubeconfig thatkubectlcannot parse. Likely undiscovered today only because the IPv6-only Talos install path is uncommon in the user base.