theforeman / smart_proxy_abrt

Automatic Bug Reporting Tool plugin for Foreman's smart-proxy
GNU General Public License v3.0
0 stars 5 forks source link

smart-proxy-abrt-send doesn't find its settings #8

Open PerilousApricot opened 8 years ago

PerilousApricot commented 8 years ago

My smart-proxy-abrt-send 0.0.8 on Centos7 with foreman 1.12 always returns that the plugin is disabled, even though the proxy says it should be enabled:

 curl -k https://foreman.localhost:8443/features           
["abrt","discovery","puppet","puppetca","salt","tftp"]

Investigating further, I added the following lines right before the error to dump the settings:

puts AbrtProxy::Plugin.settings.marshal_dump.each{ |k,v| puts "#{k} => #{v}" }

at https://github.com/theforeman/smart_proxy_abrt/blob/master/bin/smart-proxy-abrt-send#L27

But it returns what appears to be an empty setting object with "{}". I have the following as my settings:

cat /etc/foreman-proxy/settings.d/abrt.yml 

---
:enabled: true
# Log file for the forwarding script.
:abrt_send_log_file: /var/log/foreman-proxy/abrt-send.log
# Directory where uReports are stored before they are sent
:spooldir: /var/spool/foreman-proxy-abrt
# Merge duplicate reports before sending (requires the satyr gem)
:aggregate_reports: true
# Period (in seconds) after which collected reports are forwarded. Meaningful
# only if smart-proxy-abrt-send is run as a daemon (not from cron).
:send_period: 600
# FAF server instance the reports will be forwarded to (optional)
#:server_url: 
# Set to true if FAF server uses self-signed certificate
#:server_ssl_noverify: 

# Following two options enable client authentication to FAF server
#:server_ssl_cert: 
#:server_ssl_key: 

And cranking the logging on the smart proxy gives the following line, so I think it's loaded properly:

D, [2016-10-20T21:04:51.292184 #32076] DEBUG -- : 'abrt' settings: 'abrt_send_log_file': /var/log/foreman-proxy/abrt-send.log, 'aggregate_reports': true, 'enabled': true, 'send_period': 600, 'server_ssl_noverify': false (default), 'spooldir': /var/spool/foreman-proxy-abrt (default)

My ruby is ~nonexistent, but I suspect it's trying to load the settings from somewhere else. Is there a different place this should be installed?

Thanks!

mmoll commented 8 years ago

@lzap @mmilata could you have a look? :point_up:

mmilata commented 8 years ago

Sorry, I haven't worked on Foreman or ABRT for a long time so I won't be much help:( I'm not aware of any different place for the plugin settings.

@jfilak, any idea what's going on here?

jfilak commented 7 years ago

Well, we haven't touched the code base for a long time, so I suspect something has changed in loading of plugin configuration files.

Taking into account the fact that syslog contains a message with the configured values I believe the line below:

if !AbrtProxy::Plugin.settings.enabled

was evaluated before AbrtProxy::Plugin.settings was properly initialized.

@PerilousApricot Can you please confirm or reject my assumption?

lzap commented 7 years ago

Yeah I was looking into this already, didn't have time to resolve this. Something changed in plugin initialization, @witlessbird any idea?

dmitri-d commented 7 years ago

https://github.com/theforeman/smart_proxy_abrt/blob/master/bin/smart-proxy-abrt-send#L27: this doesn't work anymore. Settings loading is a part of plugin initialization process and is initialized closer to the end of it, after plugin and its providers successfully finished loading (see https://github.com/theforeman/smart-proxy/blob/develop/lib/proxy/plugin_initializer.rb#L248).

If you need to access module settings from outside of smart-proxy process you will need to load and parse settings file yourself. Alternatively, you can now run an async scheduled task inside proxy process.

lzap commented 7 years ago

Is there any documentation for the async stuff? Examples? I am not aware we have that.

dmitri-d commented 7 years ago

We are using Promises/Futures from concurrent-ruby. See https://github.com/theforeman/smart-proxy/blob/develop/modules/puppet_proxy_puppet_api/v3_environment_classes_api_classes_retriever.rb#L74 and https://github.com/theforeman/smart-proxy/pull/472/files#diff-a7b380254558ab8c9965ee50c789bf46R121 for examples (library docs are good too). Classes that implement start/stop interface can be treated as "services" and automatically started on proxy startup (for example: https://github.com/theforeman/smart-proxy/pull/472/files#diff-a7b380254558ab8c9965ee50c789bf46R174).