Commit Graph

15 Commits

Author SHA1 Message Date
Sean Sullivan
271d034e86 portforward: tunnel spdy through websockets
Kubernetes-commit: 8b447d8c97e8823b4308eb91cf7d75693e867c61
2024-02-21 08:56:07 +00:00
Brian Pursley
b0a6a6f777 portforward: Add unit test to cover stopChan usage
Kubernetes-commit: 6f08ab013c6ce54de239aab46b4086c09464f977
2022-12-23 10:11:21 -05:00
Brian Pursley
d0842249d3 portforward: return error on lost connection to pod
Currently, when the remote connection is unexpected closed, forward() prints an error message saying "lost connection to pod" via runtime.HandleError, but then it returns nil for the error.

This prevents the caller from being able to handle this error differently.

This commit changes forward() to return the "lost connection to pod" error so that it can be handled by the caller.

Making this change enables kubectl port-forward to exit with code 1, instead of 0, which is the expected behavior for a command that has failed.

Kubernetes-commit: a9f04103854893056237a09250ad3335867b0391
2022-12-13 13:32:42 -05:00
LiHui
cc3cc93e6a kubectl: fix memory leaks in port forwarding client
Signed-off-by: LiHui <andrewli@kubesphere.io>

Kubernetes-commit: 1df24569a0bf62a528c49f73fdb236fd56eb05ee
2022-08-29 14:15:01 +08:00
brianpursley
f5d063cf7a close streamConn and stop listening when an error occurs while port forwarding
Kubernetes-commit: 4a35e6c5641ee36291548c9c24b5b85663d5cd07
2021-11-16 21:05:43 -05:00
Sascha Grunert
0f6528b1f9 Cleanup portforward streams after their usage
This implements a stream cleanup when using portforwardings. Before
applying this patch, the streams []httpstream.Stream within
`spdy/connection.go` would fill-up for each streaming request. This
could result in heavy memory usage. Now we use the stream identifier to
keep track of them and finally remove them again once they're no longer
needed.

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>

Kubernetes-commit: 6459ed6717d1851f9ca28e3f245672a6a62aa0bf
2021-03-05 13:39:04 +01:00
knight42
9ff85ef8ef test(portforward): deflake TestGetListener
Signed-off-by: knight42 <anonymousknight96@gmail.com>

Kubernetes-commit: bb68741fcbe82a7b17e05e82f7a71bd0c4815e02
2020-09-09 15:40:56 +08:00
RainbowMango
532b6f676e Cleanup staticcheck issues for package in client-go.
Kubernetes-commit: c8c055b3163dd2661b3f9dd1b0ffb718a61aba24
2019-08-26 20:55:32 +08:00
Martin Helmich
e70639fd33 client-go: Dynamic local port not accessible when port-forwarding
When setting up a port forwarding with the client-go library (using the
`k8s.io/client-go/tools/portforward.PortForwarder`) with a non-defined local
port (i.e. passing `:80` as `ports` parameter to `portforward.New(...)`), a
local port will be assigned dynamically.

Currently, the local port will be _always_ 0 if it was not specified initially.
This is because the assigned local port is only set on a _copy_ of the actual
`ForwardedPort` type that is obtained in a `range` loop. This PR changes this
behaviour to set the local port at the correct instance by passing a pointer
instead of a copy to the relevant functions.

Kubernetes-commit: bbddd27f0dfffe6623763afe2c02c876ba925a7c
2019-02-03 19:01:19 +01:00
Mikalai Radchuk
bd4105de0e Fixes address parsing in port-forward
The rules for address parsing are:

* Explicitly specified addresses must bind successfully
* `localhost` is pinned to `127.0.0.1` and `::1` and at least one of those must bind successfully

This change also makes output of the command consistent
between runs with the same arguments.
Previously the command was using the range via map of addresses
which sometimes was producing different output because the order
of values is not guaranteed in Go.

Kubernetes-commit: 4ee2010111af602988bf9bedf66d1a0c36419b09
2018-11-12 00:06:35 +00:00
Radek Pieczonka
2a9c6c4210 port-forward listen on address
adds an address flag to kubectl port-forward to allow to bind to a different ip then localhost

Kubernetes-commit: 4643c6e95e0a0cf6561554fb3b9a1bc59bcead0c
2018-10-01 08:52:50 +02:00
Mike Lundy
e1ca545b2c export a method to expose which ports were forwarded
Without this change, the only method to discover what local port was
bound (if port 0 was requested) is to parse it out of the "out" stream,
which isn't the most reliable method.

Kubernetes-commit: a9084923f2bd499c287b675007cb7c6c093d60ad
2018-08-16 13:11:26 -07:00
Di Xu
d39d12f4b0 fix all the typos across the project
Kubernetes-commit: 48388fec7eaad4ac8d84fbe20673ffacf41964a1
2018-02-09 14:53:53 +08:00
Paul Michali
a08928a067 Support IPv6 addresses for getListener()
Currently, client-go requires that an IPv6 address string for hostname has
square brackets surrounding, so that it can be used with address:port in
an API request.

This change, removes that requirement, and has getListener() add the
square brackets for IPv6 addresses for hosts. If IPv4 or hostname, the name
will not be modified.

Decided to change here, rather than everywhere client-go is used (thinking
that there may be places where we DON'T want the square brackets applied).

This issue was found in kubelet, which, at startup, creates a listener for
services and nodes. If an IPv6 address is used, the URI was malformed.

Kubernetes-commit: e17a501bcb7a3d2c5f4ff5c41f122fe155395dcd
2017-07-16 03:58:42 +00:00
Kubernetes Publisher
49948ae0ca published by bot
(https://github.com/kubernetes/test-infra/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is c09311fa32be02ebb79c7959447e3e4294cc12a3
2017-02-01 03:06:37 +00:00