Commit 98c68947 authored by Kubernetes Submit Queue's avatar Kubernetes Submit Queue Committed by GitHub

Merge pull request #36549 from cjcullen/closetunnel

Automatic merge from submit-queue Close tunnels after failed healthchecks. When we fail an ssh-tunnel healthcheck, we currently leak a file descriptor keeping the SSH connection open. This closes the underlying tunnel before removing our pointer to it. It is possible that the tunnel was functional, but the healthcheck failed for some other reason (e.g. kubelet healthz down), which could close an in-use tunnel, but I think that is acceptable.
parents 2110f72e 1fdb3ee9
......@@ -380,15 +380,18 @@ func (l *SSHTunnelList) healthCheck(e sshTunnelEntry) error {
func (l *SSHTunnelList) removeAndReAdd(e sshTunnelEntry) {
// Find the entry to replace.
l.tunnelsLock.Lock()
defer l.tunnelsLock.Unlock()
for i, entry := range l.entries {
if entry.Tunnel == e.Tunnel {
l.entries = append(l.entries[:i], l.entries[i+1:]...)
l.adding[e.Address] = true
go l.createAndAddTunnel(e.Address)
return
break
}
}
l.tunnelsLock.Unlock()
if err := e.Tunnel.Close(); err != nil {
glog.Infof("Failed to close removed tunnel: %v", err)
}
go l.createAndAddTunnel(e.Address)
}
func (l *SSHTunnelList) Dial(net, addr string) (net.Conn, error) {
......
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