sonots/fluent-plugin-reemit

NoMethodError undefined method `find'

ysgard opened this issue · 13 comments

Getting this after a recent upgrade to fluentd:

2017-06-27 17:54:46 +0000 [warn]: #0 reemit: NoMethodError undefined method `find' for nil:NilClass /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluent-plugin-reemit-0.2.1/lib/fluent/plugin/out_reemit.rb:133:in `match'

using fluent 0.14.18 and fluent-plugin-reemit 0.2.1

I see that a fix was committed for this 8dbf1e5, but the gem in RubyGems doesn't have the fix.

I downloaded and built the gem, using a local gem server. However although I'm seeing the new code now, it still bombs with the same error:

2017-06-27 20:29:48 +0000 [warn]: #0 reemit: NoMethodError undefined method `find' for nil:NilClass /opt/td-agent/embedded/lib/ruby/gems/2.1.0/gems/fluent-plugin-reemit-0.2.2/lib/fluent/plugin/out_reemit.rb:154:in `match'

Looking at the code, that corresponds to this:

 def match(tag)
        # We want to reemit messages to the next `<match>` below this `type reemit`
        # to avoid reemiting back to an above or current `<match>`
        found_reemit = false
        @matches.find do |m|      <---- @matches is nil
          if m.match(tag)
            if found_reemit && !@reemit.included?(m.output)

This is being called from inside the 'V10Engine' class, but this is fluentd 14.18:

irb(main):001:0> require 'fluent/version'
=> true
irb(main):002:0> Fluent::VERSION
=> "0.14.18"
irb(main):003:0> Fluent::VERSION > '0.12'
=> true

But for some reason the V14EventRouter isn't being used. Instead a new V10Engine is initialized. So this check:

 event_router = Engine.instance_variable_get(:@event_router)

is returning nil for some reason.

I don't know how this code works. Examining the Engine instance from inside the plugin shows that it doesn't even have an 'event_router' instance variable.

Running into the same issue - so stopped using this plugin for now. Any idea @cosmo0920?

@Globegitter I think that we should request @sonots to release new version of this plugin.
Or, creating master version of this plugin with bundle exec rake build and install gem which is created under pkg/.

Thank you for reminding this to me. I've released 0.3.0.

FYI: You could've written Gemfile as:

gem 'fluent-plugin-reemit', git: 'https://github.com/sonots/fluent-plugin-reemit'

to use the master.

This is still an issue with 0.3.0.

Could you paste backtrace on the error?

2017-09-14 10:54:06 -0700 [warn]: #0 fluent/log.rb:336:warn: reemit: NoMethodError undefined method `find' for nil:NilClass /Users/ryan/.rbenv/versions/2.4.1/lib/ruby/gems/2.4.0/gems/fluent-plugin-reemit-0.3.0/lib/fluent/plugin/out_reemit.rb:154:in `match'

Thanks. I will fix.

v0.3.1 is released.

BTW, I recommend to use the label feature of Fluentd > v0.12 to achieve branching of data flow. See https://github.com/sonots/fluent-plugin-reemit#using-relabel-plugin-instead-of-reemit-plugin

If there is no extra demand, I will probably stop maintaining this plugin because the implementation of this plugin is too fragile to maintain.