Skip to content

Commit c182b6a

Browse files
authored
Add logging for errors about loading dependencies on startup (#4858)
**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 <fukuda@clear-code.com>
1 parent 60e3693 commit c182b6a

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

lib/fluent/supervisor.rb

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,18 @@ def run_supervisor(dry_run: false)
721721
$log.error 'config error', file: @config_path, error: e
722722
$log.debug_backtrace
723723
exit!(1)
724+
rescue ScriptError => e # LoadError, NotImplementedError, SyntaxError
725+
if e.respond_to?(:path)
726+
$log.error e.message, path: e.path, error: e
727+
else
728+
$log.error e.message, error: e
729+
end
730+
$log.debug_backtrace
731+
exit!(1)
732+
rescue => e
733+
$log.error "unexpected error", error: e
734+
$log.debug_backtrace
735+
exit!(1)
724736
end
725737

726738
if dry_run

test/command/test_fluentd.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ def assert_fluentd_fails_to_start(cmdline, *pattern_list, timeout: 20)
570570

571571
assert_fluentd_fails_to_start(
572572
create_cmdline(conf_path, "-p", File.dirname(plugin_path)),
573-
/in_buggy.rb:\d+:.+\(SyntaxError\)/
573+
/\[error\]: .+in_buggy.rb:\d+: syntax error/
574574
)
575575
end
576576
end

0 commit comments

Comments
 (0)