in lib/app/preflight_check.rb [72:104]
def check_es_connection_with_retries!(retry_interval:, retry_timeout:)
started_at = Time.now
begin
response = client.cluster.health
Utility::Logger.info('Successfully connected to Elasticsearch')
case response['status']
when 'green'
Utility::Logger.info('Elasticsearch is running and healthy.')
when 'yellow'
Utility::Logger.warn('Elasticsearch is running but the status is yellow.')
when 'red'
raise UnhealthyCluster, 'Elasticsearch is running but unhealthy.'
else
raise UnhealthyCluster, "Unexpected cluster status: #{response['status']}"
end
rescue *Utility::AUTHORIZATION_ERRORS => e
Utility::ExceptionTracking.log_exception(e)
fail_check!("Elasticsearch returned 'Unauthorized' response. Check your authentication details. Terminating...")
rescue *App::RETRYABLE_CONNECTION_ERRORS => e
Utility::Logger.warn('Could not connect to Elasticsearch. Make sure it is running and healthy.')
Utility::Logger.debug("Error: #{e.full_message}")
sleep(retry_interval)
time_elapsed = Time.now - started_at
retry if time_elapsed < retry_timeout
fail_check!("Could not connect to Elasticsearch after #{time_elapsed.to_i} seconds. Terminating...")
end
end