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

Exit with failure when [SERVICE] fails to process #2637

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Noremac201
Copy link

@Noremac201 Noremac201 commented Oct 5, 2020

Fluent-bit, when with only the -c flag will only [error] log PARSER parsing errors. However, this has the unintended side-effect of just not continuing parsing parsers instead of the expected parsing failure log & skip.

For example, if there is parser A, B, C, and there is an error in parser B it will get logged, but it will NOT halt the execution of the program and only parser A will be parsed/applied.

Addresses #2480

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

  • Example configuration file for the change
  • Debug log output from testing the change
  • 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.

@Noremac201
Copy link
Author

test.config

[SERVICE]
    Flush 1
    Daemon Off
    Log_Level debug
    Parsers_File parser.config

[INPUT]
    Name tail
    Path /tmp/fluentbit-test/*
    # A duplicate parser above example parser
    # will have this fail to be registered
    Parser example

[OUTPUT]
    Name stdout
    Match *

parser.config

[PARSER]
    Name   duplicate-name
    Format regex
    Regex  ^unused-regex$
    Time_Key time
    Time_Format %d/%b/%Y:%H:%M:%S %z

[PARSER]
    Name   duplicate-name
    Format regex
    Regex  ^unused-regex$
    Time_Key time
    Time_Format %d/%b/%Y:%H:%M:%S %z

[PARSER]
    Name   example
    Format regex
    Regex  ^(?<msg1>.*) (?<msg2>.*)$

To test, simply comment out one duplicate-name PARSER or make the PARSER field invalid, by removing name, etc.

@Noremac201
Copy link
Author

Debug log - duplicate parser name:

[bold@spyputs build]$ bin/fluent-bit -c test.config 
Fluent Bit v1.6.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/10/04 23:24:48] [error] [parser] parser named 'duplicate-name' already exists, skip.
Error: Configuration file contains errors. Aborting

[bold@spyputs build]$ 

debug log invalid parser config

[bold@spyputs build]$ bin/fluent-bit -c test.config 
Fluent Bit v1.6.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/10/04 23:26:54] [error] [parser] no parser 'name' found in file 'parser.config'
Error: Configuration file contains errors. Aborting

[bold@spyputs build]$ 

@Noremac201
Copy link
Author

The below is valgrind with my change.

[bold@spyputs build]$ valgrind bin/fluent-bit -c test.config
==196870== Memcheck, a memory error detector
==196870== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==196870== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==196870== Command: bin/fluent-bit -c test.config
==196870== 
Fluent Bit v1.6.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/10/04 23:45:28] [error] [parser] parser named 'duplicate-name' already exists, skip.
Error: Configuration file contains errors. Aborting

==196870== 
==196870== HEAP SUMMARY:
==196870==     in use at exit: 46,414 bytes in 100 blocks
==196870==   total heap usage: 286 allocs, 186 frees, 77,269 bytes allocated
==196870== 
==196870== LEAK SUMMARY:
==196870==    definitely lost: 0 bytes in 0 blocks
==196870==    indirectly lost: 0 bytes in 0 blocks
==196870==      possibly lost: 11,125 bytes in 85 blocks
==196870==    still reachable: 35,289 bytes in 15 blocks
==196870==         suppressed: 0 bytes in 0 blocks
==196870== Rerun with --leak-check=full to see details of leaked memory
==196870== 
==196870== For lists of detected and suppressed errors, rerun with: -s
==196870== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

The below is a valgrind at HEAD using -R instead of `Parsers_File:

[bold@spyputs build]$ valgrind bin/fluent-bit -c test.config -R parser.config 
==197408== Memcheck, a memory error detector
==197408== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==197408== Using Valgrind-3.16.1 and LibVEX; rerun with -h for copyright info
==197408== Command: bin/fluent-bit -c test.config -R parser.config
==197408== 
[2020/10/04 23:47:59] [error] [parser] parser named 'duplicate-name' already exists, skip.
==197408== 
==197408== HEAP SUMMARY:
==197408==     in use at exit: 46,354 bytes in 98 blocks
==197408==   total heap usage: 216 allocs, 118 frees, 63,483 bytes allocated
==197408== 
==197408== LEAK SUMMARY:
==197408==    definitely lost: 0 bytes in 0 blocks
==197408==    indirectly lost: 0 bytes in 0 blocks
==197408==      possibly lost: 11,094 bytes in 84 blocks
==197408==    still reachable: 35,260 bytes in 14 blocks
==197408==         suppressed: 0 bytes in 0 blocks
==197408== Rerun with --leak-check=full to see details of leaked memory
==197408== 
==197408== For lists of detected and suppressed errors, rerun with: -s
==197408== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)

@github-actions
Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

Copy link
Contributor

This PR is stale because it has been open 45 days with no activity. Remove stale label or comment or this will be closed in 10 days.

@github-actions github-actions bot added the Stale label Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant