Commit Graph

25 Commits

Author SHA1 Message Date
Maciej Szulik
bf414551df Clean error handling in port-forward
This commit introduces:
1. Cleanups in port-forwarding error handling code, which ensures that
   we only compare lowercased text always.
2. E2E verifying that when a pod is removed a port-forward is stopped.

Signed-off-by: Maciej Szulik <soltysh@gmail.com>

Kubernetes-commit: 0b1617ccefbc6ea61c0e7c2b0b4052703f11c51c
2024-10-16 14:02:01 +02:00
Nic
d6404c8d76 fix: draining remote stream after port-forward connection broken
Signed-off-by: Nic <qianyong@api7.ai>

Kubernetes-commit: dbe6b6657bacc846656f4009ee869ca996dde1da
2024-10-04 14:48:15 +08:00
Sean Sullivan
271d034e86 portforward: tunnel spdy through websockets
Kubernetes-commit: 8b447d8c97e8823b4308eb91cf7d75693e867c61
2024-02-21 08:56:07 +00: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
inosato
27de641f75 Remove ioutil from client-go
Signed-off-by: inosato <si17_21@yahoo.co.jp>

Kubernetes-commit: 88dfa51b6003c90e8f0a0508939a1d79950a40df
2022-07-30 20:54:41 +09:00
Davanum Srinivas
2a6c116e40 Generate and format files
- Run hack/update-codegen.sh
- Run hack/update-generated-device-plugin.sh
- Run hack/update-generated-protobuf.sh
- Run hack/update-generated-runtime.sh
- Run hack/update-generated-swagger-docs.sh
- Run hack/update-openapi-spec.sh
- Run hack/update-gofmt.sh

Signed-off-by: Davanum Srinivas <davanum@gmail.com>

Kubernetes-commit: a9593d634c6a053848413e600dadbf974627515f
2022-07-19 20:54:13 -04: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
Antonio Ojea
a6edfabde7 run hack/update-netparse-cve.sh
Kubernetes-commit: 0cd75e8fec62a2531637e80bb950ac9983cac1b0
2021-08-20 01:16:14 +02:00
Sukeesh
94daee0164 Cleanup: Audit log and error capitalization
Kubernetes-commit: 346fdbccf0ac06ab3fa0e51ab3b92fdc041bb4cc
2019-06-30 11:56:27 +09:00
SataQiu
185f79a1f6 fix golint failures of client-go/tools/auth client-go/tools/portforward
Kubernetes-commit: a89d75e3b822a13377373b0ef1c1969c69c616ec
2019-05-13 11:13:38 +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
Yuxiang Zhu
82ac99ce9c client-go: Fix broken TCP6 listen for port forwarding
The IPV6 loopback address `::1` is enclosed in square brackets twice,
which cause a failure to listen on the TCP6 port.

Kubernetes-commit: 942ff28e4d9da16ac4b69ac33129b9db80f67145
2017-12-20 21:29:15 +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
Chao Xu
d82cfb70dd run hack/update-staging-client-go, somehow we copied listers/<authn,authz,imagepolicy>
Kubernetes-commit: ffe74d1fe749b5887711f70af24e1375856f2520
2017-06-28 00:06:44 +00:00
Chao Xu
1e9caa8e14 run root-rewrite-import-client-go-api-types
Kubernetes-commit: f2d3220a11111f86b2f481e70e3c1ca4f5896f44
2017-06-28 00:06:44 +00:00
Chao Xu
cf012f20d0 easy changes
Kubernetes-commit: 3fa7b7824abbf3daec1189b118b91b5bb726958f
2017-04-28 20:28:25 +00:00
Yves Peter
1baf68dddb client-go PortForwarder: don't log an error if net.Listen fails
Kubernetes-commit: 99711a96a4e5fbd2bc26cbc070c96852c5939570
2017-04-21 20:28:21 +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
Kubernetes Publisher
204f12b1f3 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is 616038db1b0d1e852b4a3d10c8c512a052f91fba
2017-01-14 15:19:47 +00:00
Kubernetes Publisher
75399f68c8 published by bot
(https://github.com/kubernetes/contrib/tree/master/mungegithub)

copied from https://github.com/kubernetes/kubernetes.git, branch master,
last commit is e56cfc5322138aa23e6418ee30a6ab54c7c6fe8c
2016-10-21 04:44:19 +00:00
Chao Xu
a6d206121d remove the top-level folders for versions
remove scripts
2016-10-19 14:34:19 -07:00