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

add check_configuration option #2179

Merged
merged 2 commits into from
Dec 13, 2020

Conversation

kangaechu
Copy link
Contributor

@kangaechu kangaechu commented May 17, 2020

Added check_configuration option to validate configuration.

Fixes #2178.

I prepared conf/fluent-bit_invalid.conf and test it.
5c5

$ diff conf/fluent-bit.conf conf/fluent-bit_invalid.conf
5c5
<     Flush        5
---
>     Flush
# validate config file with valid configuration file.
$ docker run fluent-bit:latest /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf -C

Fluent Bit v1.5.0
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

configuration test is successful
$ echo $?
0

# validate config file with valid configuration file.
$ docker run fluent-bit:latest /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit.conf --check_configuration

Fluent Bit v1.5.0
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

configuration test is successful
$ echo $?
0

# validate config file with invalid configuration file.
$ docker run fluent-bit:latest /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit_invalid.conf -C
Fluent Bit v1.5.0
[2020/05/17 06:00:08] [  Error] File /fluent-bit/etc/fluent-bit_invalid.conf
[2020/05/17 06:00:08] [  Error] Error in line 5: Each key must have a value
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

$ echo $?
1

# validate config file with invalid configuration file.
$ docker run fluent-bit:latest /fluent-bit/bin/fluent-bit -c /fluent-bit/etc/fluent-bit_invalid.conf --check_configuration
Fluent Bit v1.5.0
* Copyright (C) 2019-2020 The Fluent Bit Authors
* Copyright (C) 2015-2018 Treasure Data
* Fluent Bit is a CNCF sub-project under the umbrella of Fluentd
* https://fluentbit.io

[2020/05/17 06:00:23] [  Error] File /fluent-bit/etc/fluent-bit_invalid.conf
[2020/05/17 06:00:23] [  Error] Error in line 5: Each key must have a value
$ echo $?
1

Enter [N/A] in the box, if an item is not applicable to your change.

Testing
Before we can approve your change; please submit the following in a comment:

  • [N/A] Example configuration file for the change
  • Debug log output from testing the change
  • [N/A] Attached Valgrind output that shows no leaks or memory corruption was found

Documentation

  • [N/A] Documentation required for this feature

Fluent Bit is licensed under Apache 2.0, by submitting this pull request I understand that this code will be released under the terms of that license.

@kangaechu
Copy link
Contributor Author

I am a beginner of C programmer.
So someone have any good implementation to solve this, I'll close this.

@fujimotos
Copy link
Member

fujimotos commented Jul 19, 2020

+1 for this patch, with a couple of nitpicks about the option name:

  • I'd shorten the long option to --check-config; It's probably more
    consistent with -c/--config.

  • OTOH the short option -C looks good to me. Other programs (notably
    nginx and apache) seem to use -t/--test-config for that purpose,
    but we already booked -t for -t/--tag. So I think -C is fine.

@edsiper
Copy link
Member

edsiper commented Oct 1, 2020

what about --dry-run ?

@kangaechu
Copy link
Contributor Author

kangaechu commented Oct 1, 2020

@edsiper
--dry-run is also good.
But -d option is already used for --daemon, so I will use -D instead of -d.

Signed-off-by: Satoshi Tanaka <satoshi.tanaka@crowdworks.co.jp>
Signed-off-by: Satoshi Tanaka <satoshi.tanaka@crowdworks.co.jp>
@edsiper edsiper merged commit 3ec1528 into fluent:master Dec 13, 2020
@edsiper
Copy link
Member

edsiper commented Dec 13, 2020

thanks!

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.

Add option to validate configuration
3 participants