Skip to content

Stop emitting FATAL log when checking existence of indices #982

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

Merged
merged 2 commits into from
Mar 1, 2021

Conversation

aeroastro
Copy link
Contributor

This fixes #980.

Summary

Passing ignore: 404 to Elasticsearch::Client can stop
FATAL log in addition to stopping exception.

This option is supported since the 5.0.4 and 6.0.0 of elasticsearch-ruby.
https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#600
https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#504

This swallowing was implemented following exception catching as follows.
elastic/elasticsearch-ruby@9848c97

Test

Unnecessary tests on exceptions are also removed, and following code
covers the required tests.
https://github.com/aeroastro/elasticsearch-rails/blob/c4daaad152517114aa568e326b0388ab8b883e1d/elasticsearch-model/spec/elasticsearch/model/indexing_spec.rb#L652-L661

I have confirmed that the reproduction code on #980 does not emit exceptions nor FATAL log with this patch.

Although the test on not logging FATAL [404] is omitted in this Pull Request,
I believe it is not the responsibility of Elasticsearch::Model, but that of Elasticsearch::Client.

Version Dependency

This code on master branch does not work well with
2.x and 0.1 of elasticsearch gems, where ignore: 404 option is not supported.
However, I assume the current maintenance policy does not support old versions
on master branch, and therefore the current code is O.K.

c.f. #981

Passing `ignore: 404` to Elasticsearch::Client can stop
FATAL log in addition to stopping exception.

This option is supported since the 5.0.4 and 6.0.0 of `elasticsearch-ruby`.
https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#600
https://github.com/elastic/elasticsearch-ruby/blob/36d45f0c12f4e9ef96646f269748ad33b43e974c/CHANGELOG.md#504

This swallowing was implemented following exception catching as follows.
elastic/elasticsearch-ruby@9848c97
Since we are using `ignore: 404` instead of manual
`rescue` at `Elasticsearch::Model::Indexing`,
there is no need to stub exceptions in the test.
@aeroastro
Copy link
Contributor Author

Also, this solves the false negatives on index existence which is triggered by non-404 exceptions.

@picandocodigo picandocodigo merged commit ce57cc1 into elastic:master Mar 1, 2021
@picandocodigo
Copy link
Member

Thank you very much for this contribution @aeroastro! I am adding an issue in elasticsearch-ruby for the fatal 404 in exists 👍

@aeroastro
Copy link
Contributor Author

Thank you ❤️

@aeroastro aeroastro deleted the feature/suppress-fatal-log branch March 2, 2021 03:51
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.

Want to stop noisy FATAL [404] for index checking on Elasticsearch::Persistence::Repository
2 participants