Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the current implementation when a shutdown has been requested through
a SIGTERM (or catched by ctrl-c), Fluent Bit initialized the shutdown
process and gives a grace period to wait for the active tasks to finish.
The problem with the approach is that grace period was not being respected,
actually the grace period was being renewed always waiting to flush all
the pending tasks.
This patch changes the behavior of the grace period where now the grace
period is considered (as it should) the 'maximum time to wait' for pending
tasks. If the tasks did not finished flushing under the flush period the
service will stop right away.
In addition, when no tasks exists, the patch makes the service stop before
the grace period time, since there is no need to continue waiting.
Common tests:
1. Exit before grace period
hit ctrl-c, the service will stop before grace period (at second 1 or 2).
2. Force active Tasks by using an uresponsive remote network address
on SIGTERM, the tasks will still be active because the unresponsive network,
by forcing a shutdown the grace period will be respected and the service
stop at the right moment.