Project

General

Profile

Actions

Bug #20475

closed

Implement Random DB IPAM

Added by Lukas Zapletal over 6 years ago. Updated almost 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 #1

Updated by Lukas Zapletal over 6 years ago

  • Related to Bug #20474: Multiple free IPs returned after record deletion added
Actions #2

Updated by Lukas Zapletal over 6 years ago

  • Description updated (diff)
Actions #3

Updated by The Foreman Bot over 6 years ago

  • Status changed from New to Ready For Testing
  • Assignee set to Lukas Zapletal
  • Pull request https://github.com/theforeman/foreman/pull/4716 added
Actions #4

Updated by Timo Goebel over 6 years ago

  • translation missing: en.field_release set to 240
Actions #5

Updated by Lukas Zapletal over 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100
Actions

Also available in: Atom PDF