Skip to content

Commit 31a8163

Browse files
committed
processor: fail on startup when invalid processors are configured
This change makes Fluent Bit fail to start when a configuration includes an invalid processor (one that doesn't exist or fails to initialize). Previously, Fluent Bit would log an error but continue starting up, potentially masking configuration issues. - Add early exit conditions when a processor plugin doesn't exist - Add early exit conditions when a processor plugin fails to initialize - Improve error messages to be more descriptive Part of #10305
1 parent ca2a6a5 commit 31a8163

File tree

4 files changed

+17
-6
lines changed

4 files changed

+17
-6
lines changed

src/flb_config.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -864,10 +864,16 @@ static int configure_plugins_type(struct flb_config *config, struct flb_cf *cf,
864864
processors = flb_cf_group_get(cf, s, "processors");
865865
if (processors) {
866866
if (type == FLB_CF_INPUT) {
867-
flb_processors_load_from_config_format_group(((struct flb_input_instance *) ins)->processor, processors);
867+
ret = flb_processors_load_from_config_format_group(((struct flb_input_instance *) ins)->processor, processors);
868+
if (ret == -1) {
869+
return -1;
870+
}
868871
}
869872
else if (type == FLB_CF_OUTPUT) {
870-
flb_processors_load_from_config_format_group(((struct flb_output_instance *) ins)->processor, processors);
873+
ret = flb_processors_load_from_config_format_group(((struct flb_output_instance *) ins)->processor, processors);
874+
if (ret == -1) {
875+
return -1;
876+
}
871877
}
872878
else {
873879
flb_error("[config] section '%s' does not support processors", s_type);

src/flb_input.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1338,6 +1338,7 @@ int flb_input_instance_init(struct flb_input_instance *ins,
13381338
/* initialize processors */
13391339
ret = flb_processor_init(ins->processor);
13401340
if (ret == -1) {
1341+
flb_error("[input %s] error initializing processor, aborting startup", ins->name);
13411342
return -1;
13421343
}
13431344

src/flb_output.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1428,6 +1428,7 @@ int flb_output_init_all(struct flb_config *config)
14281428
/* initialize processors */
14291429
ret = flb_processor_init(ins->processor);
14301430
if (ret == -1) {
1431+
flb_error("[output %s] error initializing processor, aborting startup", ins->name);
14311432
return -1;
14321433
}
14331434
}

src/flb_processor.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ struct flb_processor_unit *flb_processor_unit_create(struct flb_processor *proc,
274274
unit_name, NULL);
275275

276276
if (processor_instance == NULL) {
277-
flb_error("[processor] error creating native processor instance %s", pu->name);
277+
flb_error("[processor] error creating processor '%s': plugin doesn't exist or failed to initialize", unit_name);
278278

279279
pthread_mutex_destroy(&pu->lock);
280280
flb_sds_destroy(pu->name);
@@ -693,6 +693,7 @@ int flb_processor_init(struct flb_processor *proc)
693693
ret = flb_processor_unit_init(pu);
694694

695695
if (ret == -1) {
696+
flb_error("[processor] initialization of processor unit '%s' failed", pu->name);
696697
return -1;
697698
}
698699
count++;
@@ -703,6 +704,7 @@ int flb_processor_init(struct flb_processor *proc)
703704
ret = flb_processor_unit_init(pu);
704705

705706
if (ret == -1) {
707+
flb_error("[processor] initialization of processor unit '%s' failed", pu->name);
706708
return -1;
707709
}
708710
count++;
@@ -713,6 +715,7 @@ int flb_processor_init(struct flb_processor *proc)
713715
ret = flb_processor_unit_init(pu);
714716

715717
if (ret == -1) {
718+
flb_error("[processor] initialization of processor unit '%s' failed", pu->name);
716719
return -1;
717720
}
718721
count++;
@@ -723,6 +726,7 @@ int flb_processor_init(struct flb_processor *proc)
723726
ret = flb_processor_unit_init(pu);
724727

725728
if (ret == -1) {
729+
flb_error("[processor] initialization of processor unit '%s' failed", pu->name);
726730
return -1;
727731
}
728732
count++;
@@ -1199,7 +1203,7 @@ static int load_from_config_format_group(struct flb_processor *proc, int type, s
11991203
tmp = cfl_kvlist_fetch(kvlist, "name");
12001204

12011205
if (!tmp) {
1202-
flb_error("processor configuration don't have a 'name' defined");
1206+
flb_error("[processor] configuration missing required 'name' field");
12031207
return -1;
12041208
}
12051209

@@ -1208,7 +1212,6 @@ static int load_from_config_format_group(struct flb_processor *proc, int type, s
12081212
pu = flb_processor_unit_create(proc, type, name);
12091213

12101214
if (!pu) {
1211-
flb_error("cannot create '%s' processor unit", name);
12121215
return -1;
12131216
}
12141217

@@ -1217,7 +1220,7 @@ static int load_from_config_format_group(struct flb_processor *proc, int type, s
12171220
if (tmp) {
12181221
ret = flb_processor_unit_set_property(pu, "condition", tmp);
12191222
if (ret == -1) {
1220-
flb_error("failed to set condition for processor '%s'", name);
1223+
flb_error("[processor] failed to set condition for processor '%s'", name);
12211224
return -1;
12221225
}
12231226
}

0 commit comments

Comments
 (0)