Class: VagrantPlugins::Skytap::Action::WaitForCommunicator
- Inherits:
-
Vagrant::Action::Builtin::WaitForCommunicator
- Object
- Vagrant::Action::Builtin::WaitForCommunicator
- VagrantPlugins::Skytap::Action::WaitForCommunicator
- Defined in:
- lib/vagrant-skytap/action/wait_for_communicator.rb
Overview
Extends the builtin WaitForCommunicator action to retry on “network unreachable” errors, which can sometimes occur when a Skytap environment is started.
Instance Method Summary collapse
- #builtin_action_call ⇒ Object
- #call(env) ⇒ Object
-
#initialize(app, env, states = nil) ⇒ WaitForCommunicator
constructor
A new instance of WaitForCommunicator.
Constructor Details
#initialize(app, env, states = nil) ⇒ WaitForCommunicator
Returns a new instance of WaitForCommunicator.
12 13 14 15 |
# File 'lib/vagrant-skytap/action/wait_for_communicator.rb', line 12 def initialize(app, env, states=nil) super @logger = Log4r::Logger.new("vagrant_skytap::action::wait_for_communicator") end |
Instance Method Details
#builtin_action_call ⇒ Object
17 |
# File 'lib/vagrant-skytap/action/wait_for_communicator.rb', line 17 alias_method :builtin_action_call, :call |
#call(env) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-skytap/action/wait_for_communicator.rb', line 19 def call(env) # The SSH communicator handles certain exceptions by raising a # corresponding VagrantError which can be handled gracefully, # i.e. by the #wait_for_ready method, which continues to retry # until the boot_timeout expires. # # The communicator does a limited number of retries for # Errno::ENETUNREACH, but then allows the exception to bubble up # to the user. Here we swallow this exception and essentially # retry the original WaitForCommunicator action. begin Timeout.timeout(env[:machine].config.vm.boot_timeout) do while true do begin # TODO Is there a clean way to just invoke the built-in action? break builtin_action_call(env) rescue Errno::ENETUNREACH @logger.info("Rescued Errno::ENETUNREACH and retrying original WaitForCommunicator action.") env[:ui].detail("Warning: The network was unreachable. Retrying...") end return if env[:interrupted] end end rescue Timeout::Error raise Vagrant::Errors::VMBootTimeout end end |