Skip to content

Commit

Permalink
Apply product check only during registration phase
Browse files Browse the repository at this point in the history
  • Loading branch information
andsel committed Aug 20, 2021
1 parent 3b3bb6d commit 6ca5c67
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .ci/Dockerfile.elasticsearch
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ RUN rm -f $es_path/config/scripts
COPY --chown=elasticsearch:elasticsearch spec/fixtures/test_certs/* $es_path/config/test_certs/
COPY --chown=elasticsearch:elasticsearch .ci/elasticsearch-run.sh $es_path/

RUN echo "xpack.security.enabled: false" >> $es_yml

RUN if [ "$SECURE_INTEGRATION" = "true" ] ; then echo "xpack.security.http.ssl.enabled: $SECURE_INTEGRATION" >> $es_yml; fi
RUN if [ "$SECURE_INTEGRATION" = "true" ] ; then echo "xpack.security.http.ssl.key: $es_path/config/test_certs/test.key" >> $es_yml; fi
RUN if [ "$SECURE_INTEGRATION" = "true" ] ; then echo "xpack.security.http.ssl.certificate: $es_path/config/test_certs/test.crt" >> $es_yml; fi
Expand Down
12 changes: 8 additions & 4 deletions lib/logstash/outputs/elasticsearch/http_client/pool.rb
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ def sniffer_alive?
def start_resurrectionist
@resurrectionist = Thread.new do
until_stopped("resurrection", @resurrect_delay) do
healthcheck!
healthcheck!(false)
end
end
end
Expand All @@ -232,13 +232,17 @@ def health_check_request(url)
perform_request_to_url(url, :head, @healthcheck_path)
end

def healthcheck!
def healthcheck!(register_phase = true)
# 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)
if !elasticsearch?(url)
raise LogStash::ConfigurationError, "Not a valid Elasticsearch"

# when called from resurrectionist skip the product check done during register phase
if register_phase
if !elasticsearch?(url)
raise LogStash::ConfigurationError, "Not a valid Elasticsearch"
end
end
# If no exception was raised it must have succeeded!
logger.warn("Restored connection to ES instance", url: url.sanitized.to_s)
Expand Down

0 comments on commit 6ca5c67

Please sign in to comment.