-
Notifications
You must be signed in to change notification settings - Fork 306
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
Add preflight check on Elasticsearch before connecting #1026
Add preflight check on Elasticsearch before connecting #1026
Conversation
2c6d745
to
ff08c78
Compare
The red CI on case:
Is due to security "on" by default in 8.0.0. It doesn't depend on this PR, but could be solved disabling the security.
|
6ca5c67
to
46d6835
Compare
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.
I believe we can simplify the healthcheck process by reducing the number of calls to ES, and always performing the product check, which shouldn't have a performance impact.
# Try to keep locking granularity low such that we don't affect IO... | ||
@state_mutex.synchronize { @url_info.select {|url,meta| meta[:state] != :alive } }.each do |url,meta| | ||
begin | ||
health_check_request(url) | ||
|
||
# when called from resurrectionist skip the product check done during register phase | ||
if register_phase |
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.
This makes me wonder if we could just make the elasticsearch?
check everytime instead of HEAD'ing the /
?
Right after we do HEAD then we request '/' in es_version = get_es_version(url)
.
With this change we'll be doing 4 requests to ES:
- HEAD request
- GET '/' for
elasticsearch?
onregister_phase
- GET '/' to get elasticsearch version
- GET '/_license'
We can just do instead:
- GET '/' for healthcheck (and always confirm it's ES)
- GET '/_license'
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.
I agree with you, I think that point 2 and 3 could be merged or at least do one one HTTP GET call to /
.
About the HTTP HEAD, that call could use a customized path from configuration (healthcheck_path
) that some users could have customized. If we drop the HEAD call is like ignoring that setting and we should remove it.
I'm ok with removing the HEAD call, because actually seems to be used just to ping the server for reachability and then it immediately send a GET.
We could split this work in 2 steps:
- first collapse the GET call for point 2 and 3
- create a follow-up PR to drop the HEAD call and deprecate the
healthcheck_path
param
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.
create a follow-up PR to drop the HEAD call and deprecate the healthcheck_path param
It's fine if there's only an issue instead to track the goal of reducing the number of network calls for a healthcheck.
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.
Opened #1043 to track this feature
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.
other than a few cosmetic refactors the change LGTM but we need a better error message, just like in the ES input and filter.
…authenticy test, switched to direct stubbing
Co-authored-by: João Duarte <[email protected]>
Co-authored-by: João Duarte <[email protected]>
d46c39b
to
e590e04
Compare
ee6fb44
to
83d644d
Compare
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.
LGTM only minor nitpick
# Try to keep locking granularity low such that we don't affect IO... | ||
@state_mutex.synchronize { @url_info.select {|url,meta| meta[:state] != :alive } }.each do |url,meta| | ||
begin | ||
health_check_request(url) | ||
|
||
# when called from resurrectionist skip the product check done during register phase | ||
if register_phase |
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.
create a follow-up PR to drop the HEAD call and deprecate the healthcheck_path param
It's fine if there's only an issue instead to track the goal of reducing the number of network calls for a healthcheck.
Co-authored-by: João Duarte <[email protected]>
Update client behavior to match functionality of 7.14+
Tasks
LogStash::ConfigurationError: Not a valid Elasticsearch
tocould not connect to a compatible version of Elasticsearch