Skip to content

Conversation

@ganmacs
Copy link
Member

@ganmacs ganmacs commented Oct 15, 2019

Which issue(s) this PR fixes:
ref #2624

What this PR does / why we need it:

Show better log

Details

Example config

<system>
  workers 2
</system>

<worker 0>
  <source>
    @type fake
    secret very-secret-string0
    test 1
  </source>

  <match>
    @type null
  </match>
</worker>

<worker 1>
  <source>
    @type fake
    secret very-secret-string1
  </source>
  <match>
    @type null
  </match>
</worker>

normal mode

$ fluentd -c example/debug/secret.conf --dry-run

Before (supervisor and worker show same log about @type fake)

2019-10-15 15:16:44 +0900 [info]: parsing config file is succeeded path="example/debug/secret.conf"
2019-10-15 15:16:44 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:16:44 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:16:44 +0900 [info]: adding source type="fake"
2019-10-15 15:16:44 +0900 [info]: adding source type="fake"
2019-10-15 15:16:44 +0900 [info]: using configuration file: <ROOT>
  <system>
    workers 2
  </system>
  <worker 0>
    <source>
      @type fake
      secret xxxxxx
      test 1
    </source>
    <match>
      @type null
    </match>
  </worker>
  <worker 1>
    <source>
      @type fake
      secret xxxxxx
    </source>
    <match>
      @type null
    </match>
  </worker>
</ROOT>
2019-10-15 15:16:44 +0900 [warn]: parameter 'test' in <source>
  @type fake
  secret xxxxxx
  test 1
</source> is not used.
2019-10-15 15:16:44 +0900 [info]: starting fluentd-1.7.3 pid=91300 ruby="2.6.3"
2019-10-15 15:16:44 +0900 [info]: spawn command to main:  cmdline=["/Users/yuta.iwama/.rbenv/versions/2.6.3/bin/ruby", "-Eascii-8bit:ascii-8bit", "-rbundler/setup", "bin/fluentd", "-c", "example/debug/secret.conf", "-p", "plugins", "--under-supervisor"]
2019-10-15 15:16:45 +0900 [info]: #1 adding match pattern="**" type="null"
2019-10-15 15:16:45 +0900 [info]: gem 'fluentd' version '1.7.3'
2019-10-15 15:16:45 +0900 [info]: #0 adding match pattern="**" type="null"
2019-10-15 15:16:45 +0900 [info]: #0 adding source type="fake"
2019-10-15 15:16:45 +0900 [warn]: #0 parameter 'test' in <source>
  @type fake
  secret xxxxxx
  test 1
</source> is not used.

After(Removed duplicated log)

2019-10-15 15:16:44 +0900 [info]: parsing config file is succeeded path="example/debug/secret.conf"
2019-10-15 15:16:44 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:16:44 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:16:44 +0900 [info]: adding source type="fake"
2019-10-15 15:16:44 +0900 [info]: adding source type="fake"
2019-10-15 15:16:44 +0900 [info]: using configuration file: <ROOT>
  <system>
    workers 2
  </system>
  <worker 0>
    <source>
      @type fake
      secret xxxxxx
      test 1
    </source>
    <match>
      @type null
    </match>
  </worker>
  <worker 1>
    <source>
      @type fake
      secret xxxxxx
    </source>
    <match>
      @type null
    </match>
  </worker>
</ROOT>
2019-10-15 15:16:44 +0900 [warn]: parameter 'test' in <source>
  @type fake
  secret xxxxxx
  test 1
</source> is not used.

dry-run mode

$ fluentd -c example/debug/secret.conf --dry-run

Before

2019-10-15 15:16:07 +0900 [info]: parsing config file is succeeded path="example/debug/secret.conf"
2019-10-15 15:16:07 +0900 [info]: starting fluentd-1.7.3 as dry run mode ruby="2.6.3"
2019-10-15 15:16:07 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:16:07 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:16:07 +0900 [info]: adding source type="fake"
2019-10-15 15:16:07 +0900 [info]: adding source type="fake"
2019-10-15 15:16:07 +0900 [warn]: parameter 'test' in <source>
  @type fake
  secret xxxxxx
  test 1
</source> is not used.

After(show config)

2019-10-15 15:15:23 +0900 [info]: parsing config file is succeeded path="example/debug/secret.conf"
2019-10-15 15:15:23 +0900 [info]: starting fluentd-1.7.3 as dry run mode ruby="2.6.3"
2019-10-15 15:15:23 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:15:23 +0900 [info]: adding source type="fake"
2019-10-15 15:15:23 +0900 [info]: using configuration file: <ROOT>
  <system>
    workers 2
  </system>
  <worker 0>
    <source>
      @type fake
      secret xxxxxx
      test 1
    </source>
    <match>
      @type null
    </match>
  </worker>
  <worker 1>
    <source>
      @type fake
      secret xxxxxx
    </source>
    <match>
      @type null
    </match>
  </worker>
</ROOT>
2019-10-15 15:15:23 +0900 [warn]: parameter 'test' in <source>
  @type fake
  secret xxxxxx
  test 1
</source> is not used.

when config has an error

Details Example config
<system>
  workers 2
</system>

<worker 0-1>
  <source>
    @type fake
    secret very-secret-string0
    test 1
  </source>

  <match>
    @type null
  </match>
</worker>

<worker 0-1>
  <source>
    @type fake
    secret very-secret-string1
  </source>

  <match>
    @type null
  </match>
</worker>

Before

2019-10-15 15:25:41 +0900 [info]: parsing config file is succeeded path="example/debug/secret.conf"
2019-10-15 15:25:41 +0900 [info]: starting fluentd-1.7.3 as dry run mode ruby="2.6.3"
2019-10-15 15:25:41 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:25:41 +0900 [info]: adding match pattern="**" type="null"
2019-10-15 15:25:41 +0900 [info]: adding source type="fake"
2019-10-15 15:25:41 +0900 [info]: adding source type="fake"
2019-10-15 15:25:41 +0900 [warn]: parameter 'test' in <source>
  @type fake
  secret xxxxxx
  test 1
</source> is not used.

After(be able to detect an error when dry-run)

2019-10-15 15:25:37 +0900 [info]: parsing config file is succeeded path="example/debug/secret.conf"
2019-10-15 15:25:37 +0900 [info]: starting fluentd-1.7.3 as dry run mode ruby="2.6.3"
2019-10-15 15:25:37 +0900 [error]: config error file="example/debug/secret.conf" error_class=Fluent::ConfigError error="specified worker_id<0> collisions is detected on <worker> directive. Available worker id(s): []"

Docs Changes:

no need

Release Note:

Make starting log better and seal dumped config

@ganmacs ganmacs requested a review from repeatedly October 15, 2019 06:31
@ganmacs ganmacs self-assigned this Oct 15, 2019
ensure
Fluent::Engine.dry_run_mode = false
end
def configure_supervise
Copy link
Member

Choose a reason for hiding this comment

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

configure_supervisor?

This change had been introduced since
https://github.com/fluent/fluentd/pull/1580/files .

but even if dry-run mode, config need to show itself

Signed-off-by: Yuta Iwama <[email protected]>
and if supervisor_mode, worker_id returns -1 because
we need to identify worker0 and supervisor

Signed-off-by: Yuta Iwama <[email protected]>
Signed-off-by: Yuta Iwama <[email protected]>
Signed-off-by: Yuta Iwama <[email protected]>
@ganmacs
Copy link
Member Author

ganmacs commented Oct 31, 2019

I changed to fix #1576 at the same time. Could you take a look at this again? @repeatedly

2019-10-31 11:31:44 +0900 [info]: parsing config file is succeeded path="example/debug/rpc.conf"
2019-10-31 11:31:44 +0900 [info]: gem 'fluentd' version '1.8.0.rc2'
2019-10-31 11:31:44 +0900 [info]: using configuration file: <ROOT>
  <system>
    workers 2
    rpc_endpoint "127.0.0.1:9000"
  </system>
  <worker 0>
    <source>
      @type fake
      secret xxxxxx
    </source>
  </worker>
  <worker 1>
    <source>
      @type fake
      secret xxxxxx
    </source>
  </worker>
  <match>
    @type null
  </match>
</ROOT>
curl http://127.0.0.1:9000/api/config.dump                                                                                                        
{"ok":true}
2019-10-31 11:31:48 +0900 [info]: dump in-memory config
2019-10-31 11:31:48 +0900 [info]: <ROOT>
  <system>
    workers 2
    rpc_endpoint "127.0.0.1:9000"
  </system>
  <worker 0>
    <source>
      @type fake
      secret xxxxxx
    </source>
  </worker>
  <worker 1>
    <source>
      @type fake
      secret xxxxxx
    </source>
  </worker>
  <match>
    @type null
  </match>
</ROOT>

@ganmacs ganmacs added the enhancement Feature request or improve operations label Oct 31, 2019
Signed-off-by: Yuta Iwama <[email protected]>
@repeatedly repeatedly self-requested a review November 1, 2019 11:56
@ganmacs ganmacs merged commit e4a1dd7 into fluent:master Nov 5, 2019
@ganmacs ganmacs deleted the fix-dry-run-mode branch November 5, 2019 01:55
daipom added a commit that referenced this pull request Mar 7, 2025
Adds error handling similar to worker process.

Fluent::Engine.run_configure calls Fluent::Registry#search.
It can run Kernel.require.
It can raise LoadError, ConflictError and others.

Without this error handling, Fluentd cannot log those errors.
This makes a situation where Fluentd fails to start, but there
is no error log in the log file.
This solves that problem.

This appears to be an oversight of the following fix:

* #2651

Signed-off-by: Daijiro Fukuda <[email protected]>
daipom added a commit that referenced this pull request Mar 7, 2025
Adds error handling similar to worker process.
https://github.com/fluent/fluentd/blob/master/lib/fluent/supervisor.rb#L1149-L1164

`Fluent::Engine.run_configure` calls `Fluent::Registry#search`.
It can run `Kernel.require`.
It can raise `LoadError`, `ConflictError` and others.

Without this error handling, Fluentd cannot log those errors.
This makes a situation where Fluentd fails to start, but there
is no error log in the log file.
This solves that problem.

This appears to be an oversight of the following fix:

* #2651

Signed-off-by: Daijiro Fukuda <[email protected]>
daipom added a commit that referenced this pull request Mar 10, 2025
Adds error handling similar to worker process.
https://github.com/fluent/fluentd/blob/master/lib/fluent/supervisor.rb#L1149-L1164

`Fluent::Engine.run_configure` calls `Fluent::Registry#search`.
It can run `Kernel.require`.
It can raise `LoadError`, `ConflictError` and others.

Without this error handling, Fluentd cannot log those errors.
This makes a situation where Fluentd fails to start, but there
is no error log in the log file.
This solves that problem.

This appears to be an oversight of the following fix:

* #2651

Signed-off-by: Daijiro Fukuda <[email protected]>
daipom added a commit that referenced this pull request Mar 11, 2025
**Which issue(s) this PR fixes**: 
None.

**What this PR does / why we need it**: 
Adds error handling similar to worker process.

https://github.com/fluent/fluentd/blob/8df10863769da32459aba2a1408134d0b8e7d9f4/lib/fluent/supervisor.rb#L1149-L1164

`Fluent::Engine.run_configure` calls `Fluent::Registry#search`.
It can run `Kernel.require`.
It can raise `LoadError`, `ConflictError` and others.

Without this error handling, Fluentd cannot log those errors.
This makes a situation where Fluentd fails to start, but there is no
error log in the log file.
This solves that problem.

This appears to be an oversight of the following fix:

* #2651

**Docs Changes**:
Not needed.

**Release Note**: 
The same as the title.

Signed-off-by: Daijiro Fukuda <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement Feature request or improve operations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants