Fix Docker machines being lost in go side

By pruning machines that are in "unknown" status after each operation,
the Go code path exposed the fact that the Docker provider was not
updating the machine index during an "up" - leaving the state as
"unknown".

This is basically a bug within the Docker provider, so I think it's okay
to update the plugin code to correct this rather than working around the
issue in Go.

All we need to do is call `machine.state` instead of reaching through to
`machine.provider.state` while waiting for the container to be started.
That causes the extra logic for updating the machine index in
`machine.state` to fire.
This commit is contained in:
Paul Hinze 2022-07-13 14:04:32 -05:00
parent ad0a164871
commit 8d46b09a11
No known key found for this signature in database
GPG Key ID: 70B94C31D170FB29

View File

@ -16,8 +16,10 @@ module VagrantPlugins
wait = true
if !machine.provider_config.remains_running
@logger.debug("remains_running is false")
wait = false
elsif machine.provider.state.id == :running
elsif machine.state.id == :running
@logger.debug("container is already running")
wait = false
end
@ -28,7 +30,7 @@ module VagrantPlugins
# First, make sure it leaves the stopped state if its supposed to.
after = sleeper(5)
while machine.provider.state.id == :stopped
while machine.state.id == :stopped
if after[:done]
raise Errors::StateStopped
end
@ -38,7 +40,7 @@ module VagrantPlugins
# Then, wait for it to become running
after = sleeper(30)
while true
state = machine.provider.state
state = machine.state
break if state.id == :running
@logger.info("Waiting for container to run. State: #{state.id}")