mirror of
https://github.com/hashicorp/vagrant.git
synced 2026-05-28 04:36:05 -04:00
Merge pull request #13606 from allisonlarson/catch-io-timeout-error
Catch IO::Timeout when waiting for communicator
This commit is contained in:
commit
d1f699b76b
5 changed files with 15 additions and 1 deletions
|
|
@ -11,6 +11,7 @@ Vagrant.require "log4r"
|
|||
Vagrant.require "vagrant/patches/log4r"
|
||||
Vagrant.require "vagrant/patches/net-ssh"
|
||||
Vagrant.require "vagrant/patches/rubygems"
|
||||
Vagrant.require "vagrant/patches/timeout_error"
|
||||
|
||||
# Set our log levels and include trace
|
||||
Vagrant.require 'log4r/configurator'
|
||||
|
|
|
|||
5
lib/vagrant/patches/timeout_error.rb
Normal file
5
lib/vagrant/patches/timeout_error.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
# Adds an IO::TimeoutError for versions of ruby where it isn't defined (< 3.2).
|
||||
if !defined?(IO::TimeoutError)
|
||||
class IO::TimeoutError < StandardError
|
||||
end
|
||||
end
|
||||
|
|
@ -539,7 +539,7 @@ module VagrantPlugins
|
|||
rescue Errno::EACCES
|
||||
# This happens on connect() for unknown reasons yet...
|
||||
raise Vagrant::Errors::SSHConnectEACCES
|
||||
rescue Errno::ETIMEDOUT, Timeout::Error
|
||||
rescue Errno::ETIMEDOUT, Timeout::Error, IO::TimeoutError
|
||||
# This happens if we continued to timeout when attempting to connect.
|
||||
raise Vagrant::Errors::SSHConnectionTimeout
|
||||
rescue Net::SSH::AuthenticationFailed
|
||||
|
|
|
|||
|
|
@ -181,6 +181,8 @@ module VagrantPlugins
|
|||
raise Errors::SSLError, message: exception.message
|
||||
when HTTPClient::TimeoutError
|
||||
raise Errors::ConnectionTimeout, message: exception.message
|
||||
when IO::TimeoutError
|
||||
raise Errors::ConnectionTimeout
|
||||
when Errno::ETIMEDOUT
|
||||
raise Errors::ConnectionTimeout
|
||||
# This is raised if the connection timed out
|
||||
|
|
|
|||
|
|
@ -173,6 +173,12 @@ describe VagrantPlugins::CommunicatorWinRM::WinRMShell do
|
|||
expect(subject.cmd("dir").exitcode).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
it "should catch timeout errors" do
|
||||
expect(connection).to receive(:shell).with(:cmd, { })
|
||||
expect(shell).to receive(:run).with("hostname").and_raise(IO::TimeoutError)
|
||||
expect { subject.cmd("hostname") }.to raise_error(VagrantPlugins::CommunicatorWinRM::Errors::ConnectionTimeout)
|
||||
end
|
||||
end
|
||||
|
||||
describe ".wql" do
|
||||
|
|
|
|||
Loading…
Reference in a new issue