Parallels / vagrant-parallels

Vagrant Parallels Provider
https://parallels.github.io/vagrant-parallels
MIT License
996 stars 87 forks source link

Non-deterministic failure with Multi-Machine provisioning #357

Closed feliperubin closed 4 years ago

feliperubin commented 4 years ago

Vagrant Version: 2.2.9 Parallels Desktop Version 15.1.4 (47270) prlctl version 15.1.4 (47270) Host: MacBook Pro 16" 2019 i9 (octa-core), 32GB RAM Host OS: MacOS Catalina 10.15.4 Guest OS : Ubuntu 18.04 LTS

Example Vagrantfile below.

Vagrant.configure("2") do |config|

  hosts = {
    :router => { :nodes => 2, :box => "bento/ubuntu-18.04", :mem => 2048, :cpu => 2, :nestedvt => true, :linkedclone => true },
    :db => { :nodes => 1, :box => "bento/ubuntu-18.04", :mem => 1024, :cpu => 1, :nestedvt => false, :linkedclone => true },
    :gateway => { :nodes => 1, :box => "bento/ubuntu-18.04", :mem => 4096, :cpu => 2, :nestedvt => false, :linkedclone => true }
  }

  hosts.each do |k,h|
    (1..h[:nodes]).each do |i|
      hname = "#{k}"
      if h[:nodes] > 1 then 
        hname = "#{k}#{i}"
      end
      config.vm.define hname do |hnode|
        hnode.vm.synced_folder '.', '/home/vagrant/share', disabled: true
        hnode.vm.box = h[:box]
        hnode.vm.provider :parallels do |v, override|

            system "vagrant plugin install vagrant-parallels" unless Vagrant.has_plugin? "vagrant-parallels"
            v.name = hname
            v.memory = h[:mem]
            v.cpus = h[:cpu]
            if h[:nestedvt] then
              v.customize ["set", :id, "--nested-virt", "on"]
            end
            v.check_guest_tools = true
            v.update_guest_tools = true
            #Enables adaptive hypervisor, better core usage
            v.customize ["set", :id, "--adaptive-hypervisor","on"]
            v.customize ["set", :id, "--sync-ssh-ids","on"]
            v.customize ["set",:id, "--time-sync","on"]
            v.linked_clone = h[:linkedclone]
        end
      end
    end
  end
end

The following error occurs while provisioning a Multi-VM environment.


An error occurred while executing multiple actions in parallel.
Any errors that occurred are shown below.

An error occurred while executing the action on the 'router2'
machine. Please handle this error then try again:

There was an error while command execution. The command and stderr is shown below.

Command: ["/usr/local/bin/prlctl", "unregister", "9ff8208a-169c-4578-87ab-3ddb5e817c2e"]

Stderr: Failed to unregister the VM: Unable to perform the action because the virtual machine is busy. The virtual machine is being cloned. Please try again later.

I might be wrong, but it seems to be a concurrency problem; when creating a linked clone vm, it seems more than one process/thread tries to clone the original file at the same time.

vagrant_debug_flag.log

klebercabral commented 4 years ago

try before "vagrant up":

export VAGRANT_NO_PARALLEL=true

feliperubin commented 4 years ago

Sure,this works. The problem is not provisioning Parallels VMs one by one, but provisioning Parallels VMs in parallel.

dnx-seek commented 4 years ago

I also have an issue with multi machine provisioning.

Here is a snippet of my output.

❯ vagrant up
Bringing machine 'k8smaster' up with 'parallels' provider...
Bringing machine 'k8sworker1' up with 'parallels' provider...
==> k8sworker1: Registering VM image from the base box 'generic/ubuntu2004'...
==> k8sworker1: Creating new virtual machine as a linked clone of the box image...
==> k8sworker1: Unregistering the box VM image...
==> k8smaster: Creating new virtual machine as a linked clone of the box image...
==> k8smaster: An error occurred. The error will be shown after all tasks complete.

...

There was an error while command execution. The command and stderr is shown below.

Command: ["/usr/local/bin/prlctl", "clone", "4fd119bd-c03f-45ee-b879-f02e3209033f", "--name", "vagrant_temp_1604898355203_96625", "--linked", "--id", "{9e6a57ce-3ee9-420a-8abb-8da15b40c486}", "--regenerate-src-uuid"]

Stderr:
Failed to clone the VM: The virtual machine could not be found. The virtual machine is not registered in the virtual machine directory on your Mac.

It looks like the box image is being unlinked before the other VM gets to use it.

If I use export VAGRANT_NO_PARALLEL=true then it provisions fine.

legal90 commented 3 years ago

The fix for this issue has been released in vagrant-parallels v2.1.0

@feliperubin @dnx-seek Could you please verify it on your setup?

dnx-seek commented 3 years ago

@legal90 I've just taken it for a spin. Works! Thanks.

feliperubin commented 3 years ago

Seems to be working now, thanks.