Problem:
Attempting to edit & save a host that has an interface with the “Managed” flag set results in being kicked back to the edit page for the host without the save going through.
Expected outcome:
The changes to the host should be saved.
Foreman and Proxy versions:
foreman-3.1.0-1.el8.noarch
foreman-proxy-3.1.0-1.el8.noarch
Distribution and version:
CentOS 8.5
Other relevant data:
This error is reported in the smart proxy logs:
> [W] Error details for wrong number of arguments (given 2, expected 1): <ArgumentError>: wrong number of arguments (given 2, expected 1)
> /usr/share/foreman-proxy/modules/dhcp_common/server.rb:32:in `validate_supported_address'
> /usr/share/foreman-proxy/modules/dhcp/dhcp_api.rb:63:in `block in <class:DhcpApi>'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `call'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1675:in `block in compile!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (3 levels) in route!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1032:in `route_eval'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1013:in `block (2 levels) in route!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1061:in `block in process_route'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `catch'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1059:in `process_route'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1011:in `block in route!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `each'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1008:in `route!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1129:in `block in dispatch!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1124:in `dispatch!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `block in call!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `block in invoke'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `catch'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1101:in `invoke'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:939:in `call!'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:929:in `call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/method_override.rb:24:in `call'
> /usr/share/foreman-proxy/lib/proxy/log.rb:105:in `call'
> /usr/share/foreman-proxy/lib/proxy/request_id_middleware.rb:11:in `call'
> /usr/share/gems/gems/rack-protection-2.1.0/lib/rack/protection/xss_header.rb:18:in `call'
> /usr/share/gems/gems/rack-protection-2.1.0/lib/rack/protection/path_traversal.rb:16:in `call'
> /usr/share/gems/gems/rack-protection-2.1.0/lib/rack/protection/json_csrf.rb:26:in `call'
> /usr/share/gems/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
> /usr/share/gems/gems/rack-protection-2.1.0/lib/rack/protection/base.rb:50:in `call'
> /usr/share/gems/gems/rack-protection-2.1.0/lib/rack/protection/frame_options.rb:31:in `call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/null_logger.rb:11:in `call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/head.rb:12:in `call'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/show_exceptions.rb:22:in `call'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:216:in `call'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1991:in `call'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `block in call'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1769:in `synchronize'
> /usr/share/gems/gems/sinatra-2.1.0/lib/sinatra/base.rb:1542:in `call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:74:in `block in call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `each'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/urlmap.rb:58:in `call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/builder.rb:244:in `call'
> /usr/share/gems/gems/rack-2.2.3/lib/rack/handler/webrick.rb:95: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'
> /usr/share/gems/gems/logging-2.3.0/lib/logging/diagnostic_context.rb:474:in `block in create_with_logging_context'
It looks like this is due to changes made in this commit:
https://github.com/theforeman/smart-proxy/commit/eba7d3b463fca6a37ae8d047cdf8e981a96b5a10#diff-0650d3895be4e170bbcc8d6a630ced226a83598244198f9d36d2d45c7cbd252e
Specifically, it looks like the `validate_supported_address` function in `modules/dhcp_common/server.rb` is only configured to take a single argument (line 32):
> def validate_supported_address(ip)
> validate_ip(ip)
> end
While in the other places where `validate_supported_address` is also defined, it can take multiple arguments, as shown here from `modules/dhcp_common/isc/omapi_provider.rb` (line 17):
> def validate_supported_address(*args)
> args.each do |ip|
> validate_ip(ip, 4)
> end
> end
If I hand-edit the modules/dhcp_common/server.rb
file and replace the validate_supported_address
function with the one from modules/dhcp_common/isc/omapi_provider.rb
, and restart the smart proxy service, then the error goes away and I can once again save hosts with the “Managed” flag set.