Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .web-docs/components/builder/vagrant/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,6 @@ the Compress post-processor will not work with this builder.
This parameter is required when source_path have more than one provider,
or when using vagrant-cloud post-processor. Defaults to unset.

- `vagrantfile_template` (string) - What vagrantfile to use

- `teardown_method` (string) - Whether to halt, suspend, or destroy the box when the build has
completed. Defaults to "halt"

Expand Down
2 changes: 0 additions & 2 deletions builder/vagrant/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,6 @@ type Config struct {
Provider string `mapstructure:"provider" required:"false"`
// Options for the "vagrant init" command

// What vagrantfile to use
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: we should mention this in the PR name for the git history of removing this field

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general we don't squash/merge, this is already in a separate commit, so I don't think this is an issue

VagrantfileTpl string `mapstructure:"vagrantfile_template"`
// Whether to halt, suspend, or destroy the box when the build has
// completed. Defaults to "halt"
TeardownMethod string `mapstructure:"teardown_method" required:"false"`
Expand Down
2 changes: 0 additions & 2 deletions builder/vagrant/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does the Wait command always error when the Start command errors? If not we need to check the start command for ExitErrors too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Start errors if the command fails to be started, and we already check/exit if it does. The type of error doesn't matter here, and I would think this won't be an ExitError in any case, since the process won't even be created.
The problem here is if the command starts, and errors for any reason in the meantime, we didn't capture it, so even when vagrant returned non-zero, it would never report it.
TBF I'm not certain that checking the error type is relevant at all after Wait(), but I haven't dug into the complete history of the file, so it's hard to say, maybe there was a rationale for that type check. In the end for this commit I opted not to change this, but we can remove that check later if we don't think it impacts valid command executions.

Expand Down
2 changes: 2 additions & 0 deletions builder/vagrant/step_add_box.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package vagrant

import (
"context"
"fmt"
"log"
"strings"

Expand Down Expand Up @@ -93,6 +94,7 @@ func (s *StepAddBox) Run(ctx context.Context, state multistep.StateBag) multiste
// Call vagrant using prepared arguments
err := driver.Add(addArgs)
if err != nil {
err = fmt.Errorf("Failed to get box, if it is already in Vagrant, try using the `skip_add` option.\n%s", err)
state.Put("error", err)
return multistep.ActionHalt
}
Expand Down
2 changes: 0 additions & 2 deletions docs-partials/builder/vagrant/Config-not-required.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@
This parameter is required when source_path have more than one provider,
or when using vagrant-cloud post-processor. Defaults to unset.

- `vagrantfile_template` (string) - What vagrantfile to use

- `teardown_method` (string) - Whether to halt, suspend, or destroy the box when the build has
completed. Defaults to "halt"

Expand Down