-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cleanup ssh tunnels on cancel #10753
Conversation
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://git.k8s.io/community/CLA.md#the-contributor-license-agreement to sign the CLA. It may take a couple minutes for the CLA signature to be fully registered; after that, please reply here with a new comment and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Welcome @m-lima! |
Hi @m-lima. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: m-lima The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Can one of the admins verify this patch? |
/check-cla |
1 similar comment
/check-cla |
@m-lima thanks for this PR, do u mind checking if the Email u are using in the terminal is the same on that is Signed CLA in |
I used my github account to sign the CLA. Got an email confirmation on my email and it all looked good. |
@m-lima |
Sure I'll try that |
@medyagh would it be helpful or harmful if I close this PR and try it again from scratch? |
Details
In pkg/minikube/tunnel/kic/ssh_tunnel.go the interrupt signal is caught and it stops the LoadBalancerEmulator. However, it assumes that the interrupt will also propagate to the children ssh tunnels, which are running in a goroutine inside
startConnections
.The interrupt, however, kills the goroutine and the blocking call which waits for the child process to finish. This leaves the ssh tunnels dangling.
On the other hand, if
CTRL + C
is sent on the same terminal asminikube tunnel
and the clean-up routine included killing all ssh tunnels, the OS would error with "process already finished".This leads to accumulation of processes and is likely to happen. Since
minikube tunnel
is a blocking command, users will tend to detach it from the terminal and kill it with aSIGINT
(as proposed in #3647).Approaches
There are two proposed approaches. This PR takes the approach of having the tunnel know if is running or not. The second approach is to have the parent of all connections managed and know which processes should be killed.
The first approach, proposed with this PR, also addresses #8511, by letting the process owner hold the knowledge if the process is running or not. Since the ssh tunnels are started inside
startAndWait()
on pkg/minikube/tunnel/kic/ssh_conn.go, and a blocking call toWait()
is made, the owner can know when the process is started, finished, or killed.The second approach is more oriented towards the cleaning up of the ssh tunnels, and isolates changes to only pkg/minikube/tunnel/kic/ssh_tunnel.go. However it relies on
sync
. The second approach can be seen here: https://github.com/m-lima/minikube/tree/issue/10752-managed-killOutput
With this PR, users will be notified of connections being closed (as opposed to the silent death that happens now). E.g:
Also, when detaching from the terminal, all ssh tunnels will be reaped, also outputting to the terminal (if not redirected by the user). E.g:
On another terminal:
Main terminal:
fixes #10752