-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
introduce unrecoverable error type, and logs to show Fluentd process/worker started #1359
Conversation
…worker started Currently, unrecoverable errors (which serverengine doesn't try to restart workers about) are only configuration errors. But some other situation cannot be retried. For example: * per-worker root directory (will be introduced next) exists but it is a file * failed to bind an address/port in server plugin helper * failed to read a file from in_tail by permission error * or many others We are using ConfigError for such cases, but it's nonsense in fact. This change also adds unrecoverable cases for scripting errors while loading plugin files. Fluentd is now restarting for such cases, but it's just wrong behavior.
Actually, the biggest improvement in this change is testing about:
|
@repeatedly could you review this change? |
def main_process(&block) | ||
Process.setproctitle("worker:#{@process_name}") if @process_name | ||
|
||
configuration_error = false | ||
unrecoverable_error = false | ||
|
||
begin | ||
block.call | ||
rescue Fluent::ConfigError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use Fluent::ConfigError => e
and replace $!
with e
.
log.debug_backtrace | ||
end | ||
unrecoverable_error = true | ||
rescue Fluent::UnrecoverableError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
log.error_backtrace | ||
end | ||
unrecoverable_error = true | ||
rescue ScriptError # LoadError, NotImplementedError, SyntaxError |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
|
||
sub_test_case 'configuration to load plugin which raises unrecoverable error in #start' do | ||
test 'failed to start' do | ||
script = "require 'fluent/plugin/input'\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use heredocument is better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing ruby code in here document breaks indentation on my environment... :P
Others are LGTM and adding start test sis awesome. |
fa4f46a
to
1abe61a
Compare
1abe61a
to
af43194
Compare
Ruby 2.1/2.2 executes worker process via shell (command prompt) with previous code. Ruby 2.3 executes in different way (without shell), but we need to support 2.1/2.2. This fix forces to execute worker processes without shell.
c08a2c8
to
cb3b3a0
Compare
Especially on Windows, test code cannot find Fluentd process id from the result of spawn, because "exec" system call cannot be used on Windows, and we got the process id of "bundle exec" by "io.pid". It is also useful to investigate supervisor-worker relation from supervisor pid and ppid of workers.
5eb053e
to
17a4880
Compare
I added some fixes about executing worker processes and showing process ids in log. |
LGTM and good fix for windows environment 👍 |
Currently, unrecoverable errors (which serverengine doesn't try to restart workers about) are only configuration errors.
But some other situation cannot be retried. For example:
We are using ConfigError for such cases, but it's nonsense in fact.
This change also adds unrecoverable cases for scripting errors while loading plugin files.
Fluentd is now restarting for such cases, but it's just wrong behavior.