Project

General

Profile

Bug #20475

Updated by Lukas Zapletal over 6 years ago

Default implementation of DB IPAM increases numbers which creates lot of chances for race conditions when provisioning multiple hosts. 

 We should provide a random implementation that will randomize assigned IPs. It's not bullet-proof solution to the issue, but chances are much lower. 

 Workaround: 

 <pre> 
 diff --git a/app/services/ipam/db.rb b/app/services/ipam/db.rb 
 index 87291ab3c..d7adff9f6 100644 
 --- a/app/services/ipam/db.rb 
 +++ b/app/services/ipam/db.rb 
 @@ -6,7 +6,7 @@ module IPAM 
        subnet_range = IPAddr.new("#{subnet.network}/#{subnet.mask}", subnet.family).to_range 
        from = subnet.from.present? ? IPAddr.new(subnet.from) : subnet_range.first(2).last 
        to = subnet.to.present? ? IPAddr.new(subnet.to) : IPAddr.new(subnet_range.last.to_i - 2, subnet.family) 
 -        (from..to).each do |address| 
 +        (from..to).to_a.shuffle.each do |address| 
          ip = address.to_s 
          if !subnet.known_ips.include?(ip) && !excluded_ips.include?(ip) 
            logger.debug("Found #{ip}") 
 

 </pre> 

 Edit: This workaround does not work properly, can lead to huge allocation ending with OOM kill for larger subnets. This needs a proper patch.

Back