openSUSE / open-build-service

Build and distribute Linux packages from sources in an automatic, consistent and reproducible way #obs
https://openbuildservice.org
GNU General Public License v2.0
939 stars 441 forks source link

Default configuration triggers "InfluxDB: Failed to contact localhost" warnings #7963

Open seife opened 5 years ago

seife commented 5 years ago

Issue Description

The default configuration with unconfigured influxdb settings in config.yml triggers a continuous flow of these in production.log:

W, [2019-07-23T09:03:31.730738 #18201]  WARN -- InfluxDB: [18201:88136.61] Failed to contact host localhost: #<Errno::ECONNRESET: Connection reset by peer> - retrying in 30s.
W, [2019-07-23T09:03:35.630816 #18201]  WARN -- InfluxDB: [18201:88076.51] Failed to contact host localhost: #<Errno::ECONNRESET: Connection reset by peer> - retrying in 30s.
W, [2019-07-23T09:04:01.736285 #18201]  WARN -- InfluxDB: [18201:88166.62] Failed to contact host localhost: #<Errno::ECONNRESET: Connection reset by peer> - retrying in 30s.
W, [2019-07-23T09:04:05.636377 #18201]  WARN -- InfluxDB: [18201:88106.52] Failed to contact host localhost: #<Errno::ECONNRESET: Connection reset by peer> - retrying in 30s.

(My machine has a different service than influxdb running on port 8086, this is why this is not "connection refused")

Expected Result

No such warnings, no trying to connect a nonconfigured service

How to Reproduce

  1. Install OBS from RPM packages, do minimal configuration
  2. look at production.log

Further Information

I can make the warning go away by specifying empty influxdb_hosts: key in options.yml

I think the influxdb config handling is inconsistent:

src/api/config/initializers/influxdb_dj_subscriber.rb:if CONFIG['influxdb_hosts']
src/api/config/initializers/influxdb_rails.rb:if CONFIG['influxdb_hosts'].blank?
src/api/lib/backend/instrumentation.rb:      CONFIG['influxdb_hosts'].present?
src/api/lib/influxdb_obs/obs/middleware/backend_subscriber.rb:          CONFIG['influxdb_hosts'].present?

My uneducated guess is, that .blank? is false if the config is not present at all and thus this snippet from influxdb_rails.rb

if CONFIG['influxdb_hosts'].blank? # defaults to localhost otherwise
  InfluxDB::Rails.configure do |config|
    config.instrumentation_enabled = false
  end
  return
end

does not work as expected.

seife commented 5 years ago

See also this thread https://lists.opensuse.org/opensuse-buildservice/2019-07/msg00058.html where a user was at least confused by this warning when debugging a totally different issue.