Skip to content

Commit

Permalink
Close tunnels after failed healthchecks.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjcullen committed Nov 11, 2016
1 parent 860cae0 commit 1fdb3ee
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions pkg/ssh/ssh.go
Original file line number Diff line number Diff line change
Expand Up @@ -377,15 +377,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) {
Expand Down

0 comments on commit 1fdb3ee

Please sign in to comment.