fluent-plugins-nursery / fluent-plugin-systemd

This is a fluentd input plugin. It reads logs from the systemd journal.
Apache License 2.0
153 stars 43 forks source link

new version of fluentd does not auto load core libs -- fluent:latest #9

Closed jescarri closed 8 years ago

jescarri commented 8 years ago

new version of fluentd does not auto load core libs, causing lib/fluent/plugin/systemd/pos_writer.rb to die with unexpected error error=uninitialized constant Fluent::Input

jescarri commented 8 years ago
016-08-29 20:13:58 +0000 [error]: unexpected error error="uninitialized constant Fluent::Input"
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluent-plugin-systemd-0.0.3/lib/fluent/plugin/systemd/pos_writer.rb:2:in `<module:Fluent>'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluent-plugin-systemd-0.0.3/lib/fluent/plugin/systemd/pos_writer.rb:1:in `<top (required)>'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `require'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:135:in `rescue in require'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:144:in `require'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluent-plugin-systemd-0.0.3/lib/fluent/plugin/in_systemd.rb:2:in `<top (required)>'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/registry.rb:94:in `block in search'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/registry.rb:92:in `each'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/registry.rb:92:in `search'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/registry.rb:43:in `lookup'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/plugin.rb:146:in `new_impl'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/plugin.rb:100:in `new_input'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/root_agent.rb:229:in `add_source'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/root_agent.rb:95:in `block in configure'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/root_agent.rb:92:in `each'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/root_agent.rb:92:in `configure'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/engine.rb:119:in `configure'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/engine.rb:93:in `run_configure'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/supervisor.rb:620:in `run_configure'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/supervisor.rb:408:in `block in run_worker'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/supervisor.rb:553:in `call'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/supervisor.rb:553:in `main_process'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/supervisor.rb:404:in `run_worker'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/lib/fluent/command/fluentd.rb:271:in `<top (required)>'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2016-08-29 20:13:58 +0000 [error]: /usr/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
  2016-08-29 20:13:58 +0000 [error]: /var/lib/gems/2.1.0/gems/fluentd-0.14.2/bin/fluentd:5:in `<top (required)>'
  2016-08-29 20:13:58 +0000 [error]: /usr/local/bin/fluentd:23:in `load'
  2016-08-29 20:13:58 +0000 [error]: /usr/local/bin/fluentd:23:in `<main>'
jescarri commented 8 years ago

PR https://github.com/reevoo/fluent-plugin-systemd/pull/10

jescarri commented 8 years ago

I was able to make it pass almost all the tests, however there is one that seems to not work properly.

  def test_reading_from_an_invalid_pos # rubocop:disable Metrics/AbcSize
    file = File.open(pos_path, "w+")
    file.print "thisisinvalid"
    file.close

    # It continues as if the pos file did not exist
    d = create_driver(head_config)
    d.run
    assert_equal 461, d.emits.size
    assert_match(
      /\[warn\]: Could not seek to cursor thisisinvalid found in pos file: #{pos_path}/,
      d.instance.log.out.logs.first,
    )
  end

In https://github.com/reevoo/fluent-plugin-systemd/blob/master/lib/fluent/plugin/in_systemd.rb#L43-L48

seems that the log buffer is not properly initialized, or there is another way to get it back from the DummyLog module, d.instance.log.out.logs.first

errm commented 8 years ago

Thanks for your contribution. I have released a new version of the plugin