Commit dca1ecf4 authored by Dylan Griffith's avatar Dylan Griffith

Merge branch '297204-default-es-client-no-retry' into 'master'

Configure Elasticsearch Ruby client without retry by default

See merge request gitlab-org/gitlab!67273
parents a87a3d2c 1b7c3ff7
......@@ -8,6 +8,7 @@ module Gitlab
extend Gitlab::Utils::StrongMemoize
OPEN_TIMEOUT = 5
NO_RETRY = 0
# Takes a hash as returned by `ApplicationSetting#elasticsearch_config`,
# and configures itself based on those parameters
......@@ -21,7 +22,7 @@ module Gitlab
}
},
randomize_hosts: true,
retry_on_failure: true
retry_on_failure: config[:retry_on_failure] || NO_RETRY
}.compact
if config[:aws]
......
......@@ -32,6 +32,25 @@ RSpec.describe Gitlab::Elastic::Client do
expect(options).to include(open_timeout: described_class::OPEN_TIMEOUT, timeout: 30)
end
end
context 'with retry_on_failure' do
using RSpec::Parameterized::TableSyntax
where(:retry_on_failure, :client_retry) do
nil | 0 # not set or nil, no retry
false | 0 # with false, no retry
true | true # with true, retry with default times
10 | 10 # with a number N, retry N times
end
with_them do
let(:params) { { url: 'http://dummy-elastic:9200', retry_on_failure: retry_on_failure } }
it 'sets retry in transport' do
expect(client.transport.options.dig(:retry_on_failure)).to eq(client_retry)
end
end
end
end
context 'with AWS IAM static credentials' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment