Skip to content
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

shut down pipeline when finish register fails #1151

Merged

Conversation

kaisecheng
Copy link
Contributor

@kaisecheng kaisecheng commented Sep 22, 2023

Prior to this change, the errors in the post-register phase (finish_register) behaved differently: template manager logged failure; ILM setup loop printed error messages. Continuing the pipeline would not be meaningful.

With this commit, ConfigurationError is introduced for critical bootstrap failures, such as when the template path is not found. This change stops the pipeline when it gets ConfigurationError or 4xx status code calling template or ILM related API. For HTTP 429 too many request, finish_register retries the bootstrap

@kaisecheng kaisecheng linked an issue Sep 22, 2023 that may be closed by this pull request
@kaisecheng kaisecheng changed the title [WIP] shutdown pipeline when finish register fails shutdown pipeline when finish register fails Sep 28, 2023
@kaisecheng kaisecheng changed the title shutdown pipeline when finish register fails shut down pipeline when finish register fails Sep 28, 2023
@kaisecheng
Copy link
Contributor Author

kaisecheng commented Sep 28, 2023

It would be better to add integration test in core rather than in plugin to test pipeline shutdown.

Test against Logstash 6 fails. Believe we can stop testing 6.x

public_suffix-5.0.3 requires ruby version >= 2.6, which is incompatible with the current version, ruby 2.5.3p0 (jruby 9.2.7.0)

@kaisecheng kaisecheng marked this pull request as ready for review September 28, 2023 23:12
@kaisecheng kaisecheng requested a review from jsvd September 28, 2023 23:13
Comment on lines 334 to 335
@logger.error("Failed to bootstrap. Pipeline \"#{execution_context.pipeline_id}\" is going to shut down",
{ message: e.message, exception: e.class, backtrace: e.backtrace })
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@logger.error("Failed to bootstrap. Pipeline \"#{execution_context.pipeline_id}\" is going to shut down",
{ message: e.message, exception: e.class, backtrace: e.backtrace })
details = { message: e.message, exception: e.class }
details[:backtrace] = backtrace: e.backtrace if @logger.debug?
@logger.error("Failed to bootstrap. Pipeline \"#{execution_context.pipeline_id}\" is going to shut down", details)

Comment on lines 331 to 332
if respond_to?(:execution_context) && execution_context.respond_to?(:pipeline_id) &&
execution_context.respond_to?(:agent) && execution_context.agent.respond_to?(:stop_pipeline)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need all these checks? is it because during tests we may not have all these available?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see similar checking in dlq and the stop_pipeline function is added in recent two years. pipeline_id and agent are not necessary

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tracing back the history of execution_context.rb agent and pipeline_id was not there at the beginning.
Considering the execution_context was there since 2017, do you think we can safely remove and only check execution_context.agent.respond_to?(:stop_pipeline)? I can see other plugins do not check respond_to?(:execution_context)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsvd ☝️

@jsvd jsvd self-requested a review October 25, 2023 10:04
Copy link
Member

@jsvd jsvd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

lib/logstash/outputs/elasticsearch.rb Outdated Show resolved Hide resolved
lib/logstash/outputs/elasticsearch/template_manager.rb Outdated Show resolved Hide resolved
@jsvd jsvd merged commit a2674cf into logstash-plugins:main Nov 8, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unify the error behaviour for template installation and ilm
2 participants