theforeman / smart_proxy_dhcp_dnsmasq

dnsmasq DHCP plugin for Foreman smart-proxy
GNU General Public License v3.0
7 stars 7 forks source link

Error importing subnets #9

Closed d-kaylor closed 5 years ago

d-kaylor commented 5 years ago

I added this to a foreman-proxy (version 1.18) and and receive an ERF12-2600 error when trying to import subnets. The proxy log shows the following:

D, [2019-01-22T17:10:12.679099 726bb92d] DEBUG -- : Starting parse of DHCP subnets from ["/etc/dnsmasq.d/dhcp.conf"]
D, [2019-01-22T17:10:12.679185 726bb92d] DEBUG -- :   Parsing /etc/dnsmasq.d/dhcp.conf...
D, [2019-01-22T17:10:12.679532 726bb92d] DEBUG -- : Adding subnet with configuration; {:address=>"192.168.124.0", :mask=>"255.255.255.0", :range=>["192.168.124.127", "192.168.124.254"], :ttl=>43200}
E, [2019-01-22T17:10:12.679970 726bb92d] ERROR -- : undefined method `[]' for nil:NilClass
D, [2019-01-22T17:10:12.679994 726bb92d] DEBUG -- : undefined method `[]' for nil:NilClass (NoMethodError)
/usr/share/foreman-proxy/modules/dhcp_common/subnet.rb:25:in `initialize'
/usr/local/share/gems/gems/smart_proxy_dhcp_dnsmasq-0.6/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb:108:in `new'
/usr/local/share/gems/gems/smart_proxy_dhcp_dnsmasq-0.6/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb:108:in `parse_config_for_subnet'
/usr/local/share/gems/gems/smart_proxy_dhcp_dnsmasq-0.6/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb:21:in `load!'
/usr/local/share/gems/gems/smart_proxy_dhcp_dnsmasq-0.6/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_main.rb:18:in `initialize'
/usr/local/share/gems/gems/smart_proxy_dhcp_dnsmasq-0.6/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_configuration.rb:20:in `new'
/usr/local/share/gems/gems/smart_proxy_dhcp_dnsmasq-0.6/lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_configuration.rb:20:in `block in load_dependency_injection_wirings'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:10:in `instance'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:59:in `get_dependency'
/usr/share/foreman-proxy/lib/proxy/dependency_injection.rb:76:in `block in inject_attr'
/usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:14:in `block in <class:DhcpApi>'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1635:in `call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1635:in `block in compile!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:992:in `block (3 levels) in route!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1011:in `route_eval'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:992:in `block (2 levels) in route!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1040:in `block in process_route'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1038:in `catch'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1038:in `process_route'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:990:in `block in route!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:989:in `each'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:989:in `route!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1097:in `block in dispatch!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1076:in `block in invoke'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1076:in `catch'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1076:in `invoke'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1094:in `dispatch!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:924:in `block in call!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1076:in `block in invoke'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1076:in `catch'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1076:in `invoke'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:924:in `call!'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:913:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/method_override.rb:22:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/common_logger.rb:33:in `call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:231:in `call'
/usr/share/foreman-proxy/lib/proxy/log.rb:109:in `call'
/usr/share/foreman-proxy/lib/proxy/request_id_middleware.rb:9:in `call'
/usr/share/gems/gems/rack-protection-2.0.5/lib/rack/protection/xss_header.rb:18:in `call'
/usr/share/gems/gems/rack-protection-2.0.5/lib/rack/protection/path_traversal.rb:16:in `call'
/usr/share/gems/gems/rack-protection-2.0.5/lib/rack/protection/json_csrf.rb:26:in `call'
/usr/share/gems/gems/rack-protection-2.0.5/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.0.5/lib/rack/protection/base.rb:50:in `call'
/usr/share/gems/gems/rack-protection-2.0.5/lib/rack/protection/frame_options.rb:31:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/null_logger.rb:9:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/head.rb:12:in `call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/show_exceptions.rb:22:in `call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:194:in `call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1957:in `call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1502:in `block in call'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1729:in `synchronize'
/usr/share/gems/gems/sinatra-2.0.5/lib/sinatra/base.rb:1502:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/urlmap.rb:68:in `block in call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/urlmap.rb:53:in `each'
/usr/share/gems/gems/rack-2.0.6/lib/rack/urlmap.rb:53:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/builder.rb:153:in `call'
/usr/share/gems/gems/rack-2.0.6/lib/rack/handler/webrick.rb:86:in `service'
/usr/share/ruby/webrick/httpserver.rb:140:in `service'
/usr/share/ruby/webrick/httpserver.rb:96:in `run'
/usr/share/ruby/webrick/server.rb:307:in `block in start_thread'

I can provide additional info if that helps. Thanks.

ananace commented 5 years ago

I pushed a quick fix that should hopefully solve the issue for you,

I can't push a release right now, but you can patch lib/smart_proxy_dhcp_dnsmasq/dhcp_dnsmasq_subnet_service.rb, just change line 46 to be;

configuration = { options: {} }
d-kaylor commented 5 years ago

That resolved the issue for me. Both smart_proxy_dhcp_dnsmasq and smart_proxy_dns_dnsmasq are working great for me now.

ananace commented 5 years ago

This is now fixed on the latest release too, so closing the issue.