Project

General

Profile

Actions

Bug #19533

closed

undefined method `find_host_by_mac' for nil:NilClass

Added by Adam Winberg about 8 years ago. Updated almost 8 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
DHCP plugin
Difficulty:
Triaged:
Fixed in Releases:
Found in Releases:

Description

After upgrading to 1.15 I get an error when a new host try to notify Foreman that the build is done via the REST API.

I'm using the infoblox dhcp provider.

production.log:

2017-05-12 10:25:47 88006fe4 [app] [I] unattended: lxserv1690.smhi.se is Built!
2017-05-12 10:25:47 88006fe4 [app] [W] ProxyAPI operation FAILED
 | ProxyAPI::ProxyException: ERF12-4395 [ProxyAPI::ProxyException]: Unable to retrieve DHCP entry for 00:50:56:93:8a:ac ([RestClient::BadRequest]: 400 Bad Request) for proxy https://lxserv753.smhi.se:8443/dhcp
 | /usr/share/foreman/lib/proxy_api/dhcp.rb:53:in `rescue in record'
 | /usr/share/foreman/lib/proxy_api/dhcp.rb:43:in `record'
 | /usr/share/foreman/lib/net/dhcp/record.rb:44:in `conflicts'
 | /usr/share/foreman/lib/net.rb:23:in `conflicting?'
 | /usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:198:in `block in dhcp_conflict_detected?'
 | /usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:198:in `any?'
 | /usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:198:in `dhcp_conflict_detected?'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:228:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:228:in `block in halting_and_conditional'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `block in call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `each'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_validation_callbacks'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activemodel-4.2.5.1/lib/active_model/validations/callbacks.rb:113:in `run_validations!'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activemodel-4.2.5.1/lib/active_model/validations.rb:338:in `valid?'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:58:in `valid?'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:86:in `valid?'
 | /usr/share/foreman/app/models/host/managed.rb:961:in `trigger_nic_orchestration'

So I went digging in the changelog for 15.1, and found one commit related to DHCP: http://projects.theforeman.org/issues/17533

So I first reverted the change from that PR to the 'record' definition in 'lib/proxy_api/dhcp.rb'. That yielded a different error:

2017-05-12 11:04:05 abcb421f [app] [I] unattended: lxserv1690.smhi.se is Built!
2017-05-12 11:04:06 abcb421f [app] [W] ProxyAPI operation FAILED
 | ProxyAPI::ProxyException: ERF12-4395 [ProxyAPI::ProxyException]: Unable to retrieve DHCP entry for 172.29.1.103 ([RestClient::BadRequest]: 400 Bad Request) for proxy https://lxserv753.smhi.se:8443/dhcp
 | /usr/share/foreman/lib/proxy_api/dhcp.rb:74:in `rescue in records_by_ip'
 | /usr/share/foreman/lib/proxy_api/dhcp.rb:62:in `records_by_ip'
 | /usr/share/foreman/lib/net/dhcp/record.rb:44:in `conflicts'
 | /usr/share/foreman/lib/net.rb:23:in `conflicting?'
 | /usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:198:in `block in dhcp_conflict_detected?'
 | /usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:198:in `any?'
 | /usr/share/foreman/app/models/concerns/orchestration/dhcp.rb:198:in `dhcp_conflict_detected?'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:432:in `block in make_lambda'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:228:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:228:in `block in halting_and_conditional'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `block in call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `each'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:506:in `call'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:92:in `__run_callbacks__'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activesupport-4.2.5.1/lib/active_support/callbacks.rb:778:in `_run_validation_callbacks'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activemodel-4.2.5.1/lib/active_model/validations/callbacks.rb:113:in `run_validations!'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activemodel-4.2.5.1/lib/active_model/validations.rb:338:in `valid?'
 | /opt/rh/sclo-ror42/root/usr/share/gems/gems/activerecord-4.2.5.1/lib/active_record/validations.rb:58:in `valid?'
 | /usr/share/foreman/app/models/concerns/orchestration.rb:86:in `valid?'
 | /usr/share/foreman/app/models/host/managed.rb:961:in `trigger_nic_orchestration'

This is related to a new definition in the same file, 'records_by_ip'. Since I had nothing to revert to and my ruby skills are very limited, I instead reverted the change where this new def is called, in the 'conflicts' def in 'lib/net/dhcp/record.rb'.

After these two reverts my build notification worked again. Not sure if this is a bug in the new 1.15 release or if it's related to me using the infoblox dhcp provider?

Actions

Also available in: Atom PDF