frapposelli / vagrant-vcloud

Vagrant provider for VMware vCloud Director®
MIT License
67 stars 38 forks source link

enhance default port range above 2200..2250 #58

Closed StefanScherer closed 10 years ago

StefanScherer commented 10 years ago

Today, I encountered a problem with port forwardings. Using more and more vApps in parallel, one box could not be created correctly, even after a vagrant destroy -f spooler3 and vagrant up spooler3.

The debug log showed me

057.997 ERR  INFO handle_port_collisions: Attempting to repair FP collision: 8080
057.997 ERR  INFO handle_port_collisions: Repaired port also in use: 2200.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2201.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2202.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2203.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2204.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2205.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2206.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2207.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2208.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2209.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2210.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2211.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2212.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2213.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2214.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2215.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2216.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2217.Trying another...
057.998 ERR  INFO handle_port_collisions: Repaired port also in use: 2218.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2219.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2220.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2221.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2223.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2224.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2225.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2226.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2227.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2228.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2229.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2230.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2231.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2232.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2233.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2234.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2235.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2236.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2237.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2238.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2239.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2240.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2241.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2242.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2243.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2244.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2245.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2246.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2247.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired port also in use: 2248.Trying another...
057.999 ERR  INFO handle_port_collisions: Repaired FP collision: 8080 to 2249
057.999 ERR  INFO interface: info: Fixed port collision for 8080 => 8080. Now on port 2249.
058.000 ERR  INFO interface: info: ==> spooler3: Fixed port collision for 8080 => 8080. Now on port 2249.
058.000 OUT                         </VmRule>
058.000 ERR  INFO handle_port_collisions: Attempting to repair FP collision: 5515
058.000 OUT                     </NatRule>
058.000 OUT                 </NatService>
058.000 OUT             </Features>
058.000 OUT             <SyslogServerSettings/>
058.000 OUT             <RouterInfo>
058.000 OUT                 <ExternalIp>10.115.4.9</ExternalIp>
058.000 OUT             </RouterInfo>
058.000 OUT         </Configuration>
058.000 OUT         <IsDeployed>true</IsDeployed>
058.000 OUT     </NetworkConfig>
058.001 OUT </NetworkConfigSection>
058.001 OUT ==> spooler3: Fixed port collision for 8080 => 8080. Now on port 2249.
058.002 ERR  INFO handle_port_collisions: Repaired FP collision: 5515 to 2250
058.003 ERR  INFO interface: info: Fixed port collision for 5515 => 5515. Now on port 2250.
058.003 ERR  INFO interface: info: ==> spooler3: Fixed port collision for 5515 => 5515. Now on port 2250.
058.003 ERR  INFO handle_port_collisions: Attempting to repair FP collision: 2222
058.003 ERR ERROR warden: Error occurred: uninitialized constant VagrantPlugins::VCloud::Errors::ForwardPortAutolistEmpty
058.003 ERR  INFO warden: Beginning recovery process...
058.003 ERR  INFO warden: Recovery complete.
058.003 ERR ERROR warden: Error occurred: uninitialized constant VagrantPlugins::VCloud::Errors::ForwardPortAutolistEmpty
058.003 ERR  INFO warden: Beginning recovery process...
058.003 ERR  INFO warden: Recovery complete.
058.003 ERR ERROR warden: Error occurred: uninitialized constant VagrantPlugins::VCloud::Errors::ForwardPortAutolistEmpty
058.003 ERR  INFO warden: Beginning recovery process...
058.003 ERR  INFO warden: Calling recover: #<Vagrant::Action::Builtin::Call:0x007f56e91c9e08>
058.003 ERR  INFO warden: Beginning recovery process...

Always problem after port 2250. So I went down into the vagrant sources and found it.

$ grep -r usable_port_range .
./plugins/kernel_v1/config/vm.rb:        new.vm.usable_port_range = self.auto_port_range if self.auto_port_range
./plugins/kernel_v2/config/vm.rb:      attr_accessor :usable_port_range
./plugins/kernel_v2/config/vm.rb:        @usable_port_range            = UNSET_VALUE
./plugins/kernel_v2/config/vm.rb:        if @usable_port_range == UNSET_VALUE
./plugins/kernel_v2/config/vm.rb:          @usable_port_range = (2200..2250)

It is also mentioned in the Vagrant docs, so it is worth mentioning to increase config.vm.usable_port_range to more than 2200..2250.

The default port range ist 2200..2250 and will be too small using vCloud very fast. Probably we should handle that situation better than crashing.

So others might find these lines useful in a global Vagrantfile:

  if Vagrant.has_plugin?("vagrant-vcloud")
    config.vm.provider :vcloud do |cloud, override|
      config.vm.usable_port_range = 2200..2999
    end
  end
tsugliani commented 10 years ago

Hi @StefanScherer,

Yes very good observation, I think we should add this to our documentation in the Wiki. I'll flag it as invalid and close this as it's not inherent to vagrant-vcloud but more as a default value in vagrant.

I will add your solution into the vagrant-vcloud wiki.

tsugliani commented 10 years ago

Wiki page available here: https://github.com/frapposelli/vagrant-vcloud/wiki/Increase-vagrant-default-port-range-for-larger-deployments.