Merge pull request #57457 from vfreex/fix-port-forward-ipv6

Automatic merge from submit-queue. 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>.

client-go: Fix broken TCP6 listen for port forwarding

**What this PR does / why we need it**:
The IPV6 loopback address `::1` is enclosed in square brackets twice,
which cause a failure to listen on the TCP6 port.

**Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*:

**Special notes for your reviewer**:

**Release note**:

```release-note
Fix an issue where port forwarding doesn't forward local TCP6 ports to the pod
```
/area ipv6
/sig cli

Kubernetes-commit: a241087f9966deef6175a370da060f9623e92d94
This commit is contained in:
Kubernetes Publisher
2018-01-31 04:06:46 -08:00
2 changed files with 55 additions and 55 deletions

106
Godeps/Godeps.json generated
View File

@@ -400,215 +400,215 @@
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/equality", "ImportPath": "k8s.io/apimachinery/pkg/api/equality",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/errors", "ImportPath": "k8s.io/apimachinery/pkg/api/errors",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/meta", "ImportPath": "k8s.io/apimachinery/pkg/api/meta",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/resource", "ImportPath": "k8s.io/apimachinery/pkg/api/resource",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing", "ImportPath": "k8s.io/apimachinery/pkg/api/testing",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/api/testing/fuzzer",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip", "ImportPath": "k8s.io/apimachinery/pkg/api/testing/roundtrip",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/announced",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered", "ImportPath": "k8s.io/apimachinery/pkg/apimachinery/registered",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/fuzzer",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/internalversion",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1", "ImportPath": "k8s.io/apimachinery/pkg/apis/meta/v1alpha1",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion", "ImportPath": "k8s.io/apimachinery/pkg/conversion",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams", "ImportPath": "k8s.io/apimachinery/pkg/conversion/queryparams",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/fields", "ImportPath": "k8s.io/apimachinery/pkg/fields",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/labels", "ImportPath": "k8s.io/apimachinery/pkg/labels",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime", "ImportPath": "k8s.io/apimachinery/pkg/runtime",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/schema", "ImportPath": "k8s.io/apimachinery/pkg/runtime/schema",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/json",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/protobuf",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/recognizer",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/streaming",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning", "ImportPath": "k8s.io/apimachinery/pkg/runtime/serializer/versioning",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/selection", "ImportPath": "k8s.io/apimachinery/pkg/selection",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/types", "ImportPath": "k8s.io/apimachinery/pkg/types",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/cache", "ImportPath": "k8s.io/apimachinery/pkg/util/cache",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/clock", "ImportPath": "k8s.io/apimachinery/pkg/util/clock",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/diff", "ImportPath": "k8s.io/apimachinery/pkg/util/diff",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/errors", "ImportPath": "k8s.io/apimachinery/pkg/util/errors",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/framer", "ImportPath": "k8s.io/apimachinery/pkg/util/framer",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy", "ImportPath": "k8s.io/apimachinery/pkg/util/httpstream/spdy",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/intstr", "ImportPath": "k8s.io/apimachinery/pkg/util/intstr",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/json", "ImportPath": "k8s.io/apimachinery/pkg/util/json",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch", "ImportPath": "k8s.io/apimachinery/pkg/util/mergepatch",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/net", "ImportPath": "k8s.io/apimachinery/pkg/util/net",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand", "ImportPath": "k8s.io/apimachinery/pkg/util/remotecommand",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/runtime", "ImportPath": "k8s.io/apimachinery/pkg/util/runtime",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/sets", "ImportPath": "k8s.io/apimachinery/pkg/util/sets",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch", "ImportPath": "k8s.io/apimachinery/pkg/util/strategicpatch",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation", "ImportPath": "k8s.io/apimachinery/pkg/util/validation",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/validation/field", "ImportPath": "k8s.io/apimachinery/pkg/util/validation/field",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/wait", "ImportPath": "k8s.io/apimachinery/pkg/util/wait",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/util/yaml", "ImportPath": "k8s.io/apimachinery/pkg/util/yaml",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/version", "ImportPath": "k8s.io/apimachinery/pkg/version",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/pkg/watch", "ImportPath": "k8s.io/apimachinery/pkg/watch",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/json",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/netutil",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect", "ImportPath": "k8s.io/apimachinery/third_party/forked/golang/reflect",
"Rev": "b621949a1923cee3fce8bca9613e9a83609f0bbc" "Rev": "150d32b09b5966b39cb02d7945f0d1bc7b9f1a19"
}, },
{ {
"ImportPath": "k8s.io/kube-openapi/pkg/util/proto", "ImportPath": "k8s.io/kube-openapi/pkg/util/proto",

View File

@@ -185,7 +185,7 @@ func (pf *PortForwarder) forward() error {
// If both listener creation fail, an error is raised. // If both listener creation fail, an error is raised.
func (pf *PortForwarder) listenOnPort(port *ForwardedPort) error { func (pf *PortForwarder) listenOnPort(port *ForwardedPort) error {
errTcp4 := pf.listenOnPortAndAddress(port, "tcp4", "127.0.0.1") errTcp4 := pf.listenOnPortAndAddress(port, "tcp4", "127.0.0.1")
errTcp6 := pf.listenOnPortAndAddress(port, "tcp6", "[::1]") errTcp6 := pf.listenOnPortAndAddress(port, "tcp6", "::1")
if errTcp4 != nil && errTcp6 != nil { if errTcp4 != nil && errTcp6 != nil {
return fmt.Errorf("All listeners failed to create with the following errors: %s, %s", errTcp4, errTcp6) return fmt.Errorf("All listeners failed to create with the following errors: %s, %s", errTcp4, errTcp6)
} }
@@ -220,7 +220,7 @@ func (pf *PortForwarder) getListener(protocol string, hostname string, port *For
} }
port.Local = uint16(localPortUInt) port.Local = uint16(localPortUInt)
if pf.out != nil { if pf.out != nil {
fmt.Fprintf(pf.out, "Forwarding from %s:%d -> %d\n", hostname, localPortUInt, port.Remote) fmt.Fprintf(pf.out, "Forwarding from %s -> %d\n", net.JoinHostPort(hostname, strconv.Itoa(int(localPortUInt))), port.Remote)
} }
return listener, nil return listener, nil