Commit b3bb149e authored by Sean McGivern's avatar Sean McGivern

Merge branch 'fix-elastic-transport-error' into 'master'

Fix Elasticsearch BadRequest exception

See merge request gitlab-org/gitlab!24280
parents 3a0f2ff5 165c9e2d
......@@ -5,6 +5,8 @@ module Elastic
module Routing
extend ActiveSupport::Concern
ES_ROUTING_MAX_COUNT = 128
def routing_options(options)
return {} if Feature.disabled?(:elasticsearch_use_routing)
return {} if options[:public_and_internal_projects]
......@@ -31,6 +33,8 @@ module Elastic
private
def build_routing(ids)
return [] if ids.count > ES_ROUTING_MAX_COUNT
ids.map { |id| "project_#{id}" }.join(',')
end
end
......
......@@ -63,6 +63,12 @@ describe Elastic::Latest::Routing do
expect(subject.routing_options(options)).to eq({ routing: project_routing })
end
it 'returns empty hash when there are too many project_ids' do
max_count = included_class::ES_ROUTING_MAX_COUNT
expect(subject.routing_options({ project_ids: 1.upto(max_count + 1).to_a })).to eq({})
end
end
context 'when feature flag is disabled' 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