From 57442a0663162e49bad0e0fa4bc4e64a087973b8 Mon Sep 17 00:00:00 2001 From: Andrew Hayworth Date: Fri, 31 Oct 2025 16:01:57 -0500 Subject: [PATCH 1/2] bin: run additional validation for --dry-run MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit There are certain kinds of invalid configurations that pass the `--dry-run` check, but fail to start at run time. This commit addresses the issue by re-using some of the hot reload validation logic. For example, this config is trivially invalid, passes `--dry-run`, and fails at runtime: ``` pipeline: inputs: - name: dummy tag: test invalid_property_that_does_not_exist: some_value outputs: - name: stdout match: '*' ``` ``` zsh ❮ fluent-bit --dry-run -c ~/tmp/fbconfig-bad-property.yaml Fluent Bit v4.1.1 * Copyright (C) 2015-2025 The Fluent Bit Authors * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd * https://fluentbit.io ______ _ _ ______ _ _ ___ __ | ___| | | | | ___ (_) | / | / | | |_ | |_ _ ___ _ __ | |_ | |_/ /_| |_ __ __/ /| | `| | | _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / / /_| | | | | | | | |_| | __/ | | | |_ | |_/ / | |_ \ V /\___ |__| |_ \_| |_|\__,_|\___|_| |_|\__| \____/|_|\__| \_/ |_(_)___/ configuration test is successful zsh ❮ fluent-bit -c ~/tmp/fbconfig-bad-property.yaml Fluent Bit v4.1.1 * Copyright (C) 2015-2025 The Fluent Bit Authors * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd * https://fluentbit.io ______ _ _ ______ _ _ ___ __ | ___| | | | | ___ (_) | / | / | | |_ | |_ _ ___ _ __ | |_ | |_/ /_| |_ __ __/ /| | `| | | _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / / /_| | | | | | | | |_| | __/ | | | |_ | |_/ / | |_ \ V /\___ |__| |_ \_| |_|\__,_|\___|_| |_|\__| \____/|_|\__| \_/ |_(_)___/ [2025/10/31 16:05:55.268532000] [ info] [fluent bit] version=4.1.1, commit=, pid=21037 [2025/10/31 16:05:55.268808000] [ info] [storage] ver=1.5.3, type=memory, sync=normal, checksum=off, max_chunks_up=128 [2025/10/31 16:05:55.269140000] [ info] [simd ] disabled [2025/10/31 16:05:55.269147000] [ info] [cmetrics] version=1.0.5 [2025/10/31 16:05:55.269407000] [ info] [ctraces ] version=0.6.6 [2025/10/31 16:05:55.269476000] [error] [config] dummy: unknown configuration property 'invalid_property_that_does_not_exist'. The following properties are allowed: samples, dummy, metadata, rate, interval_sec, interval_nsec, copies, start_time_sec, start_time_nsec, fixed_timestamp, flush_on_startup, and test_hang_on_exit. [2025/10/31 16:05:55.269486000] [ help] try the command: fluent-bit -i dummy -h [2025/10/31 16:05:55.269515000] [error] [engine] input initialization failed ``` With this commit, we can see that the additional validation from hot reload catches the error right away: ``` zsh ❯ bin/fluent-bit --dry-run -c ~/tmp/fbconfig-bad-property.yaml Fluent Bit v4.2.0 * Copyright (C) 2015-2025 The Fluent Bit Authors * Fluent Bit is a CNCF sub-project under the umbrella of Fluentd * https://fluentbit.io ______ _ _ ______ _ _ ___ __ | ___| | | | | ___ (_) | / | / | | |_ | |_ _ ___ _ __ | |_ | |_/ /_| |_ __ __/ /| | `| | | _| | | | | |/ _ \ '_ \| __| | ___ \ | __| \ \ / / /_| | | | | | | | |_| | __/ | | | |_ | |_/ / | |_ \ V /\___ |__| |_ \_| |_|\__,_|\___|_| |_|\__| \____/|_|\__| \_/ |_(_)___/ [2025/10/31 16:07:50.402568000] [error] [config] dummy: unknown configuration property 'invalid_property_that_does_not_exist'. The following properties are allowed: samples, dummy, metadata, rate, interval_sec, interval_nsec, copies, start_time_sec, start_time_nsec, fixed_timestamp, flush_on_startup, and test_hang_on_exit. [2025/10/31 16:07:50.402792000] [ help] try the command: bin/fluent-bit -i dummy -h [2025/10/31 16:07:50.402800000] [error] [reload] check properties for input plugins is failed ``` (The logs of course now say `[reload]`, which is a little misleading... we can clean that up, if desired). Signed-off-by: Andrew Hayworth --- src/fluent-bit.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/fluent-bit.c b/src/fluent-bit.c index 4b2cd6655f2..8e0013c8b4f 100644 --- a/src/fluent-bit.c +++ b/src/fluent-bit.c @@ -1430,6 +1430,11 @@ static int flb_main_run(int argc, char **argv) #endif if (config->dry_run == FLB_TRUE) { + ret = flb_reload_property_check_all(config); + if (ret != 0) { + exit(EXIT_FAILURE); + } + fprintf(stderr, "configuration test is successful\n"); flb_init_env(); flb_cf_destroy(cf_opts); From 538df01359f8c4da10dcad24df13b9f1041fa165 Mon Sep 17 00:00:00 2001 From: Andrew Hayworth Date: Mon, 3 Nov 2025 10:21:43 -0600 Subject: [PATCH 2/2] bin: ensure we clean up after error and successful dry-run We need to perform the same partial initialization and releasing of resources whether or not the dry-run was successful, so this commit ensures that we call those functions before exiting either way. Signed-off-by: Andrew Hayworth --- src/fluent-bit.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/fluent-bit.c b/src/fluent-bit.c index 8e0013c8b4f..65df0dee732 100644 --- a/src/fluent-bit.c +++ b/src/fluent-bit.c @@ -1431,14 +1431,16 @@ static int flb_main_run(int argc, char **argv) if (config->dry_run == FLB_TRUE) { ret = flb_reload_property_check_all(config); - if (ret != 0) { - exit(EXIT_FAILURE); - } - fprintf(stderr, "configuration test is successful\n"); + /* At this point config test is done, so clean up after ourselves */ flb_init_env(); flb_cf_destroy(cf_opts); flb_destroy(ctx); + + if (ret != 0) { + exit(EXIT_FAILURE); + } + fprintf(stderr, "configuration test is successful\n"); exit(EXIT_SUCCESS); }