Module: SSHKit::Backend::Netssh::ReconnectOnStaleConnection
- Included in:
- SSHKit::Backend::Netssh
- Defined in:
- lib/dash/sshkit_with_ext.rb
Overview
A pooled session that sat idle while dash was busy elsewhere (a server-lock
wait, a loadbalancer reboot) gets dropped by NATs and cloud networks without
either end noticing: net-ssh only sends keepalives from inside its event
loop, and the pool's liveness probe is a non-blocking process(0), so the
session looks fine until the first command on it dies. Evict that session
and rerun the block once on a fresh connection.
The block is rerun, so a drop mid-command runs the command twice. That is accepted: the errors here are the idle-drop ones, where nothing reached the server, and the alternative is the deploy failing on the next host.
Constant Summary collapse
- STALE_CONNECTION_ERRORS =
[ Errno::ECONNRESET, Errno::EPIPE, Net::SSH::Disconnect, Net::SSH::Timeout ].freeze