Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix NameError of SecondaryFileOutput when setting secondary other than out_secondary_file #4124

Merged
merged 1 commit into from
Apr 3, 2023

Conversation

daipom
Copy link
Contributor

@daipom daipom commented Apr 3, 2023

Which issue(s) this PR fixes:
None.

Fix bug of 3a796cd

What this PR does / why we need it:

In Fluentd v1.16.0, the following setting causes NameError and Fluentd to fail to start.

<match test.**>
  @type stdout
  <buffer>
    @type memory
  </buffer>
  <secondary>
    @type file
    path /tmp/backup/
  </secondary>
</match>

Error

$ bundle exec fluentd -c .\fluent\fluent.conf
2023-04-03 18:49:11 +0900 [info]: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2023-04-03 18:49:11 +0900 [info]: parsing config file is succeeded path=".\\fluent\\fluent.conf"
2023-04-03 18:49:11 +0900 [info]: gem 'fluentd' version '1.16.0'
C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin/output.rb:429:in `configure': uninitialized constant Fluent::Plugin::Output::SecondaryFileOutput (NameError)

          if (@secondary.class != SecondaryFileOutput) &&
                                  ^^^^^^^^^^^^^^^^^^^
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin_helper/formatter.rb:83:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin_helper/inject.rb:104:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin/out_stdout.rb:52:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/plugin.rb:187:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/agent.rb:132:in `add_match'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/agent.rb:74:in `block in configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/agent.rb:64:in `each'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/agent.rb:64:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/root_agent.rb:149:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/engine.rb:105:in `configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/engine.rb:80:in `run_configure'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/supervisor.rb:571:in `run_supervisor'
        from C:/Users/reang/Documents/work/fluentd/fluentd/lib/fluent/command/fluentd.rb:352:in `<top (required)>'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from <internal:C:/Ruby32-x64/lib/ruby/site_ruby/3.2.0/rubygems/core_ext/kernel_require.rb>:37:in `require'
        from C:/Users/reang/Documents/work/fluentd/fluentd/bin/fluentd:15:in `<top (required)>'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/bin/fluentd:25:in `load'
        from C:/Ruby32-x64/lib/ruby/gems/3.2.0/bin/fluentd:25:in `<main>'

This PR fixes this bug.

In #4087, I could not notice this error since this error would not occur if out_secondary_file is set once before such a setting.
I'm sorry for my careless mistake.

Docs Changes:
Not needed.

Release Note:
Same as the title.

Fix bug of 3a796cd (fluent#4087)

Signed-off-by: Daijiro Fukuda <[email protected]>
@daipom daipom changed the title Fix NameError of SecondaryFileOutput when secondary other than out_secondary_file is set Fix NameError of SecondaryFileOutput when setting secondary other than out_secondary_file Apr 3, 2023
@ashie
Copy link
Member

ashie commented Apr 3, 2023

We noticed this issue in fluent/fluent-package-builder#436

@ashie ashie modified the milestones: v1.16.0, v1.16.1 Apr 3, 2023
@daipom
Copy link
Contributor Author

daipom commented Apr 3, 2023

I confirmed this behavior.

Config:

<match test.**>
  @type stdout
  @id file
  <buffer>
    @type memory
  </buffer>
  <secondary>
    @type file
    path /tmp/backup/
  </secondary>
</match>

<match test.**>
  @type stdout
  @id secondary_file
  <buffer>
    @type memory
  </buffer>
  <secondary>
    @type secondary_file
    directory /tmp/backup
  </secondary>
</match>

Run Fluentd:

$ bundle exec fluentd -c .\fluent\fluent.conf
2023-04-03 19:04:23 +0900 [info]: init supervisor logger path=nil rotate_age=nil rotate_size=nil
2023-04-03 19:04:23 +0900 [info]: parsing config file is succeeded path=".\\fluent\\fluent.conf"
2023-04-03 19:04:23 +0900 [info]: gem 'fluentd' version '1.16.0'
2023-04-03 19:04:23 +0900 [warn]: [file] Use different plugin for secondary. Check the plugin works with primary like secondary_file primary="Fluent::Plugin::StdoutOutput" secondary="Fluent::Plugin::FileOutput"
2023-04-03 19:04:23 +0900 [info]: using configuration file: <ROOT>
  <match test.**>
    @type stdout
    @id file
    <buffer>
      @type "memory"
    </buffer>
    <secondary>
      @type "file"
      path "/tmp/backup/"
      <buffer time>
        path /tmp/backup/
      </buffer>
    </secondary>
  </match>
  <match test.**>
    @type stdout
    @id secondary_file
    <buffer>
      @type "memory"
    </buffer>
    <secondary>
      @type "secondary_file"
      directory "/tmp/backup"
    </secondary>
  </match>
</ROOT>
2023-04-03 19:04:23 +0900 [info]: starting fluentd-1.16.0 pid=5300 ruby="3.2.0"
2023-04-03 19:04:23 +0900 [info]: spawn command to main:  cmdline=["C:/Ruby32-x64/bin/ruby.exe", "-rC:/Ruby32-x64/lib/ruby/gems/3.2.0/gems/bundler-2.4.8/lib/bundler/setup", "-Eutf-8", "C:/Ruby32-x64/lib/ruby/gems/3.2.0/bin/fluentd", "-c", ".\\fluent\\fluent.conf", "--under-supervisor"]
2023-04-03 19:04:26 +0900 [info]: #0 init worker0 logger path=nil rotate_age=nil rotate_size=nil
2023-04-03 19:04:26 +0900 [info]: adding match pattern="test.**" type="stdout"
2023-04-03 19:04:26 +0900 [warn]: #0 [file] Use different plugin for secondary. Check the plugin works with primary like secondary_file primary="Fluent::Plugin::StdoutOutput" secondary="Fluent::Plugin::FileOutput"
2023-04-03 19:04:26 +0900 [info]: adding match pattern="test.**" type="stdout"
2023-04-03 19:04:26 +0900 [info]: #0 starting fluentd worker pid=22656 ppid=5300 worker=0
2023-04-03 19:04:26 +0900 [info]: #0 fluentd worker is now running worker=0
  • No NameError.
  • The plugin with out_file for its secondary gets warning.
  • The plugin with out_secondary_file for its secondary doesn't get warning.

Copy link
Member

@ashie ashie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ashie ashie merged commit d28b114 into fluent:master Apr 3, 2023
@daipom daipom deleted the fix-nameerror-secondaryfileoutput branch April 4, 2023 00:46
@daipom
Copy link
Contributor Author

daipom commented Apr 4, 2023

Thanks for your review!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants