Handle VM not accessible during reboot (#1367)

To support commands requesting a reboot of a VM after execution, the
query of ssh_info needs to avoid triggering an error when the IP address
is not yet retrievable as this indicates the VM would not be reachable.

Wrap the returning of the state in the driver to distinguish between the
following states:
- :running - indicates the machine is available
- :inaccessible - the machine is running but not yet available to
  connect

This is based on the behaviour from the virtualbox provider.

Includes some rudimentary tests to exercise the driver state code.

Closes: #1366
This commit is contained in:
Darragh Bailey
2021-09-30 13:35:30 +01:00
committed by GitHub
parent 64c096b040
commit 81b6fb715a
5 changed files with 124 additions and 26 deletions

View File

@@ -137,7 +137,17 @@ module VagrantPlugins
# TODO: terminated no longer appears to be a valid fog state, remove?
return :not_created if domain.nil? || domain.state.to_sym == :terminated
domain.state.tr('-', '_').to_sym
state = domain.state.tr('-', '_').to_sym
if state == :running
begin
get_domain_ipaddress(machine, domain)
rescue Fog::Errors::TimeoutError => e
@logger.debug("Machine #{machine.id} running but no IP address available: #{e}.")
return :inaccessible
end
end
return state
end
private