What happened?
On IPv6-only Kubernetes clusters, the Trident CSI node plugin can fail to register with the CSI controller when Kubernetes service-link environment variables are present for the trident-csi Service.
The node plugin reads TRIDENT_CSI_SERVICE_HOST and TRIDENT_CSI_SERVICE_PORT to construct the controller REST endpoint. When the host is an IPv6 literal, the constructed endpoint is not a valid URL because the IPv6 host is not bracketed. For example, a service host like 2001:db8::10 and port 34571 becomes:
https://2001:db8::10:34571
Go's URL parsing then interprets part of the IPv6 address as the port and returns an error similar to:
invalid port ":db8::10:34571" after host
As a result, CreateNode cannot log into the Trident CSI controller and the node plugin does not become ready.
Expected behavior
The controller REST endpoint should be valid for IPv4 addresses, DNS names, and IPv6 literals. For IPv6 literals it should be constructed as:
https://[2001:db8::10]:34571
Proposed fix
Use net.JoinHostPort(host, port) when assembling the controller host and port before prepending the https:// scheme. This preserves existing IPv4/DNS behavior and brackets IPv6 literals correctly.
Affected versions
I confirmed the unbracketed URL construction is present in tags v26.02.1 and v26.06.0, and it is still present on the current master branch at the time of filing.
Additional context
I plan to submit a small pull request with the net.JoinHostPort fix and unit coverage for IPv6, IPv4, and DNS host inputs.
What happened?
On IPv6-only Kubernetes clusters, the Trident CSI node plugin can fail to register with the CSI controller when Kubernetes service-link environment variables are present for the
trident-csiService.The node plugin reads
TRIDENT_CSI_SERVICE_HOSTandTRIDENT_CSI_SERVICE_PORTto construct the controller REST endpoint. When the host is an IPv6 literal, the constructed endpoint is not a valid URL because the IPv6 host is not bracketed. For example, a service host like2001:db8::10and port34571becomes:Go's URL parsing then interprets part of the IPv6 address as the port and returns an error similar to:
As a result,
CreateNodecannot log into the Trident CSI controller and the node plugin does not become ready.Expected behavior
The controller REST endpoint should be valid for IPv4 addresses, DNS names, and IPv6 literals. For IPv6 literals it should be constructed as:
Proposed fix
Use
net.JoinHostPort(host, port)when assembling the controller host and port before prepending thehttps://scheme. This preserves existing IPv4/DNS behavior and brackets IPv6 literals correctly.Affected versions
I confirmed the unbracketed URL construction is present in tags
v26.02.1andv26.06.0, and it is still present on the currentmasterbranch at the time of filing.Additional context
I plan to submit a small pull request with the
net.JoinHostPortfix and unit coverage for IPv6, IPv4, and DNS host inputs.