Unverified Commit fa2ea528 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #57846 from dims/fix-external-address-parsing-under-ipv6

Automatic merge from submit-queue (batch tested with PRs 56315, 57846). If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. Fix ExternalAddress parsing problem under IPv6 **What this PR does / why we need it**: `!strings.Contains(host, ":") ` will fail miserably under ipv6 **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: **Release note**: ```release-note NONE ```
parents c02f5485 c258d4df
...@@ -342,10 +342,10 @@ func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedCo ...@@ -342,10 +342,10 @@ func (c *Config) Complete(informers informers.SharedInformerFactory) CompletedCo
if host == "" && c.PublicAddress != nil { if host == "" && c.PublicAddress != nil {
host = c.PublicAddress.String() host = c.PublicAddress.String()
} }
if !strings.Contains(host, ":") {
if c.ReadWritePort != 0 { // if there is no port, and we have a ReadWritePort, use that
host = net.JoinHostPort(host, strconv.Itoa(c.ReadWritePort)) if _, _, err := net.SplitHostPort(host); err != nil && c.ReadWritePort != 0 {
} host = net.JoinHostPort(host, strconv.Itoa(c.ReadWritePort))
} }
c.ExternalAddress = host c.ExternalAddress = host
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment