Problem:
We have the problem that we can’t provision newly discovered host, because a lease already exists from the PXE boot. It fails silently on the GUI however in the foreman-proxy.log shows that there is a record already existing. However, the code checks whether the record requested is identical to the one existing and if so it just overrides it. (Which should be the case in my scenario.) Unfortunately, the API request is missing the hardware_type option and therefore the requested record and the existing record diverge. Here is the corresponding log from the foreman-proxy.log:
2020-03-16T20:32:54 47ccb30d [W] Request to create a conflicting DHCP record
2020-03-16T20:32:54 47ccb30d [D] request: #<Proxy::DHCP::Reservation:0x0055f8c0de8bb8 @type="reservation", @name="hostname", @subnet=#<Proxy::DHCP::Subnet:0x0055f8bff7e078 @network="10.0.0.0", @netmask="255.255.
248.0", @ipaddr=#<IPAddr: IPv4:10.0.0.0/255.255.248.0>, @options={:routers=>["10.0.0.1"], :domain_name_servers=>["10.
0.0.5", "10.0.0.3"], :ntp_servers=>[["ntp"]], :range=>["10.0.0.20", "10.0.6.255"]}, @m=#<Monitor:0x0055f8c0b5f7c0 @mo
n_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0055f8c0b5f770>>, @netmask_to_i=4294965248>, @ip="10.0.3.37",
@mac="f2:f4:60:fd:db:c6", @options={:deleteable=>true, :hostname=>"hostname"}>
2020-03-16T20:32:54 47ccb30d [D] existing: [#<Proxy::DHCP::Reservation:0x0055f8c09fcb58 @type="reservation", @name="hostname", @subnet=#<Proxy::DHCP::Subnet:0x0055f8bff7e078 @network="10.0.0.0", @netmask="255.25
5.248.0", @ipaddr=#<IPAddr: IPv4:10.0.0.0/255.255.248.0>, @options={:routers=>["10.0.0.1"], :domain_name_servers=>["1
0.0.0.5", "10.0.0.3"], :ntp_servers=>[["ntp"]], :range=>["10.0.0.20", "10.0.6.255"]}, @m=#<Monitor:0x0055f8c0b5f7c0 @
mon_owner=nil, @mon_count=0, @mon_mutex=#<Thread::Mutex:0x0055f8c0b5f770>>, @netmask_to_i=4294965248>, @ip="10.0.3.37
", @mac="f2:f4:60:fd:db:c6", @options={:deleteable=>true, :hostname=>"hostname", :hardware_typ
e=>"ethernet"}>]
2020-03-16T20:32:54 47ccb30d [E] Record 10.0.0.0/10.0.3.37 already exists
2020-03-16T20:32:54 47ccb30d [W] Record 10.0.0.0/10.0.3.37 already exists
Proxy::DHCP::Collision: Record 10.0.0.0/10.0.3.37 already exists
/usr/share/foreman-proxy/modules/dhcp_common/server.rb:157:in `add_record'
/usr/share/foreman-proxy/modules/dhcp_common/isc/omapi_provider.rb:29:in `add_record'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:98:in `block in <class:DhcpApi>'
/usr/lib/ruby/vendor_ruby/sinatra/base.rb:1611:in `call'
...
A diff of the requested and the existing record shows that the :hardware_typ e=>"ethernet"
is missing in the requested record.
... foreman-proxy/modules/dhcp_common/server.rb
145 if similar_records.any? {|record| record == to_return}
146 # we already got this record, no need to do anything
147 logger.debug "We already got the same DHCP record - skipping"
148 raise Proxy::DHCP::AlreadyExists
149 end
150
151 unless similar_records.empty?
152 logger.warn "Request to create a conflicting DHCP record"
153 logger.debug "request: #{to_return.inspect}"
154 logger.debug "existing: #{similar_records.inspect}"
155 raise Proxy::DHCP::Collision, "Record #{subnet.network}/#{ip_address} already exists"
156 end
...
Expected outcome:
A error in the GUI with the possibility to override the entry.
Send the hardware_type field in the request to the proxies DHCP endpoint.
Foreman and Proxy versions:
foreman/buster,now 1.24.2-1 amd64 [installed]
foreman-proxy/stretch,now 1.24.2-1 all [installed]
Foreman and Proxy plugin versions:
ruby-foreman-discovery/plugins,now 16.0.1-1 all [installed]
Distribution and version:
SMP Debian 4.9.189-3+deb9u2 - Stretch (Proxy)
SMP Debian 4.19.67-2+deb10u2 - Buster (Master)
Thank you everyone!
Bind regards
Florian