Skip to content

Vagrant can't bring up multiple machine environments #12867

@chrisroberts

Description

@chrisroberts

Description

Vagrant is not properly tracking port forwards to prevent collisions on subsequent vagrant ups. Port forward collision checking is happening on the ruby side and the details are not properly persisted for the vagrant-go side return the information to the port modifying action. Underlying issue is within the vagrantfile configuration changes not being preserved when passed back and forth between ruby and go.

Use case (optional)

Users can bring up multiple machines without errors of port collisions.

Supporting material

related: #12854

For a Vagrantfile for example:

Vagrant.configure("2") do |config|
  config.vm.define "one" do |c|
    c.vm.hostname = "one"
    c.vm.usable_port_range = 8070..8090
    c.vm.box = "hashicorp/bionic64"
    c.vm.synced_folder ".", "vagrant", disabled: true
  end

  config.vm.define "two" do |c|
    c.vm.hostname = "two"
    c.vm.usable_port_range = 8070..8090
    c.vm.box = "hashicorp/bionic64"
    c.vm.synced_folder ".", "vagrant", disabled: true
  end
end

Vagrant should be able to bring up the machines successfully. Instead, Vagrant will hang on bringing up the second guest. This is caused by Vagrant trying to apply port forwards for both guests on the local host port 2222. Here is an bit from the vagrant up log

  ==> one: Forwarding ports...
      one: 22 (guest) => 2222 (host) (adapter 1)
  ==> one: Booting VM...
  ==> one: Waiting for machine to boot. This may take a few minutes...
      one: SSH address: 127.0.0.1:2222

...

  ==> two: Forwarding ports...
      two: 22 (guest) => 2222 (host) (adapter 1)
  ==> two: Booting VM...
  ==> two: Waiting for machine to boot. This may take a few minutes...
      two: SSH address: 127.0.0.1:2222

So, the second Vagrant machine will error on not being able to connect to the vm

two: Warning: Authentication failure. Retrying...
...

Estimated task complexity time-frame (does not guarantee a delivery date)

  • 1 day
  • 1 week
  • 2-3 weeks

This should be mostly solved by fixing configuration handling. After that is fixed this should just be verified as working.

Estimated user impact

Major: addresses a frequent request

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions