Bug #37698
openREX script provider failes to load with smart-proxy log level set to WARN
Description
When the loglevel in /etc/foreman-proxy/settings.yml is set to WARN (and probably also with UNKNOWN), the smart-proxy script feature fails to load.
The relevant error in the log is:
2024-07-30T08:41:23 [E] Couldn't enable 'script'
2024-07-30T08:41:23 [W] Error details for Couldn't enable 'script': <NoMethodError>: undefined method `last' for nil:NilClass
/usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.10.4/lib/smart_proxy_remote_execution_ssh.rb:89:in `block in validate_ssh_log_level!'
/usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.10.4/lib/smart_proxy_remote_execution_ssh.rb:88:in `map'
/usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.10.4/lib/smart_proxy_remote_execution_ssh.rb:88:in `validate_ssh_log_level!'
/usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.10.4/lib/smart_proxy_remote_execution_ssh.rb:75:in `validate_ssh_settings!'
/usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.10.4/lib/smart_proxy_remote_execution_ssh.rb:11:in `validate!'
/usr/share/gems/gems/smart_proxy_remote_execution_ssh-0.10.4/lib/smart_proxy_remote_execution_ssh/plugin.rb:48:in `block in <class:Plugin>'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:228:in `class_eval'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:228:in `configure_plugin'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:109:in `block in configure'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:109:in `each'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:109:in `configure'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:187:in `each'
/usr/share/foreman-proxy/lib/proxy/plugin_initializer.rb:187:in `initialize_plugins'
/usr/share/foreman-proxy/lib/launcher.rb:129:in `launch'
/usr/share/foreman-proxy/bin/smart-proxy:6:in `<main>'
- Install a smart-proxy with the remote-execution-script feature
- set log level to "WARN" in /etc/foreman-proxy/settings.yml
- Restart the smart-proxy service
- Either this should be caught via https://github.com/theforeman/smart_proxy_remote_execution_ssh/blob/master/lib/smart_proxy_remote_execution_ssh.rb#L81 and reported via a proper error message or
- Loglevel should be dropped to the next less-verbose level silently without a failure to load the entire module
This was found with Remote Execution 12.0.5 and remote_execution_ssh 0.10.4, but looking at the code the relevant parts were not changed since then.
No data to display