Project

General

Profile

Actions

Bug #19533

closed

undefined method `find_host_by_mac' for nil:NilClass

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

Updated by Dominic Cleal almost 7 years ago

  • Status changed from New to Need more information

Which version is your smart proxy running?

Can you please provide /var/log/foreman-proxy/proxy.log when the error occurs? The error is different between your two examples, but both are reporting an error code from the smart proxy, so its logs will contain the reason.

Actions #2

Updated by Adam Winberg almost 7 years ago

Ah, you're right - see the errors from the proxy log below. I'm running foreman-proxy-1.15.0-1.el7.noarch. (and rubygem-smart_proxy_dhcp_infoblox-0.0.5-1.fm1_14.el7.noarch)

Error output on first error:

E, [2017-05-12T10:25:47.523226 ] ERROR -- : undefined method `find_host_by_mac' for nil:NilClass
D, [2017-05-12T10:25:47.523286 ] DEBUG -- : undefined method `find_host_by_mac' for nil:NilClass (NoMethodError)
/usr/share/foreman-proxy/modules/dhcp_common/server.rb:62:in `find_record_by_mac'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:81:in `block in <class:DhcpApi>'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `call'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `block in compile!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `[]'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:994:in `route_eval'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (2 levels) in route!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1015:in `block in process_route'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `catch'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1013:in `process_route'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:973:in `block in route!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `each'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:972:in `route!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1085:in `block in dispatch!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `block in invoke'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `catch'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1067:in `invoke'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1082:in `dispatch!'
...

Error output on second error:


E, [2017-05-12T11:14:33.989629 ] ERROR -- : undefined method `find_hosts_by_ip' for nil:NilClass
D, [2017-05-12T11:14:33.989680 ] DEBUG -- : undefined method `find_hosts_by_ip' for nil:NilClass (NoMethodError)
/usr/share/foreman-proxy/modules/dhcp_common/server.rb:68:in `find_records_by_ip'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:67:in `block in <class:DhcpApi>'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `call'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:1611:in `block in compile!'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `[]'
/usr/share/gems/gems/sinatra-1.4.7/lib/sinatra/base.rb:975:in `block (3 levels) in route!'
...

Actions #3

Updated by Dominic Cleal almost 7 years ago

  • Project changed from Foreman to Infoblox
  • Subject changed from Notifying Foreman of finished new build gives "[ProxyAPI::ProxyException]: Unable to retrieve DHCP entry ..." to undefined method `find_host_by_mac' for nil:NilClass
  • Category changed from DHCP to DHCP plugin
  • Status changed from Need more information to New

Possibly a bug in the plugin, not having subnet_service defined internally.

Actions #4

Updated by Adam Winberg almost 7 years ago

I had another problem with the infoblox plugin after the update, which was more obvious to me that it was related to the plugin. I registered an issue on github for this, but maybe this is related?

https://github.com/theforeman/smart_proxy_dhcp_infoblox/issues/25

Actions #5

Updated by Anonymous over 6 years ago

  • Status changed from New to Closed
  • Pull request https://github.com/theforeman/smart_proxy_dhcp_infoblox/pull/26 added

Resolved in commit cb5fde9866d3b2672ed03ff70dc044d3b03834c3

Actions

Also available in: Atom PDF