Skip to content

Commit

Permalink
driver: act on vagrant errors
Browse files Browse the repository at this point in the history
When executing a Vagrant command, the driver would never error, unless
the call to `Start` actually errored.
This is problematic, as when there's a problem with a Vagrant command,
it doesn't get forwarded to the caller, and no error might be reported.

This problem stems from a modification in commit b0c799c,
which changed how the command was invoked, as previously it used
`Run()` (a combination of Start and Wait), and now it split both calls
in two so the outputs of the command can be processed before sending
them back.
However, that change did not account for errors in `Wait`, which is
where the process actually returns an error if it ends with a non-zero
error code, making all commands from `vagrant` not report their errors
to the driver.
  • Loading branch information
lbajolet-hashicorp committed Feb 14, 2024
1 parent 8073e23 commit 95fd7f2
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion builder/vagrant/driver_2_2.go
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ func (d *Vagrant_2_2_Driver) vagrantCmd(args ...string) (string, string, error)
log.Printf("[vagrant driver] stdout: %s", line)
stdoutString += line + "\n"
}
_ = cmd.Wait()
err = cmd.Wait()

if _, ok := err.(*exec.ExitError); ok {
err = fmt.Errorf("Vagrant error: %s", stderrString)
Expand Down

0 comments on commit 95fd7f2

Please sign in to comment.