Project

General

Profile

Actions

Bug #20475

closed

Implement Random DB IPAM

Added by Lukas Zapletal over 7 years ago. Updated over 6 years ago.

Status:
Closed
Priority:
Normal
Category:
DHCP
Target version:
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

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:

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}")

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


Related issues 1 (0 open1 closed)

Related to Smart Proxy - Bug #20474: Multiple free IPs returned after record deletionClosed08/01/2017Actions
Actions

Also available in: Atom PDF