communicators/ssh: timeout on connection check

This commit is contained in:
Mitchell Hashimoto 2014-10-21 16:59:34 -07:00
parent 7f432422e1
commit 5ebd10c19c
2 changed files with 7 additions and 1 deletions

View File

@ -2,6 +2,7 @@
BUG FIXES: BUG FIXES:
- core: Fix cases where sometimes SSH connection would hang.
- providers/docker: Create args works. [GH-4526] - providers/docker: Create args works. [GH-4526]
- providers/virtualbox: Show a human-friendly error if VirtualBox didn't - providers/virtualbox: Show a human-friendly error if VirtualBox didn't
clean up an existing VM. [GH-4681] clean up an existing VM. [GH-4681]

View File

@ -265,8 +265,13 @@ module VagrantPlugins
# There is a chance that the socket is closed despite us checking # There is a chance that the socket is closed despite us checking
# 'closed?' above. To test this we need to send data through the # 'closed?' above. To test this we need to send data through the
# socket. # socket.
#
# We wrap the check itself in a 5 second timeout because there
# are some cases where this will just hang.
begin begin
@connection.exec!("") Timeout.timeout(5) do
@connection.exec!("")
end
rescue Exception => e rescue Exception => e
@logger.info("Connection errored, not re-using. Will reconnect.") @logger.info("Connection errored, not re-using. Will reconnect.")
@logger.debug(e.inspect) @logger.debug(e.inspect)