Skip to content
Snippets Groups Projects
Commit f3afcc41 authored by John Mason's avatar John Mason
Browse files

Add inclusion parameter for Search::IndexCurator

Changelog: changed
EE: true
parent e2d8b3fc
No related branches found
No related tags found
1 merge request!103951Add inclusion parameter for Search::IndexCurator
......@@ -5,6 +5,11 @@ class IndexCurationWorker
include ApplicationWorker
include Gitlab::ExclusiveLeaseHelpers
CURATOR_SETTINGS = {
ignore_patterns: [/.*/],
include_patterns: [/notes/]
}.freeze
data_consistency :always
# There is no onward scheduling and this cron handles work from across the
......@@ -20,7 +25,7 @@ def perform
return unless Feature.enabled?(:search_index_curation)
in_lock(self.class.name.underscore, ttl: 10.minutes, retries: 10, sleep_sec: 1) do
::Gitlab::Search::IndexCurator.curate.each do |rolled_over_index|
::Gitlab::Search::IndexCurator.curate(settings: CURATOR_SETTINGS).each do |rolled_over_index|
logger.info("Rollover: #{rolled_over_index[:from]} => #{rolled_over_index[:to]}")
end
end
......
......@@ -11,6 +11,7 @@ class IndexCurator
min_docs_before_rollover: 100_000,
max_docs_shard_count: 5,
ignore_patterns: [/migrations/],
include_patterns: [],
index_pattern: 'gitlab*'
}.freeze
......@@ -91,6 +92,8 @@ def primary_shard_size_too_big?(index_info)
end
def should_ignore_index?(index_info)
return false if settings[:include_patterns].any? { |p| p.match? index_info['index'] }
settings[:ignore_patterns].any? { |p| p.match? index_info['index'] }
end
......
......@@ -237,6 +237,16 @@
expect(curator).not_to be_should_ignore_index(index_info)
end
end
context 'when index name matches one of the ignore pattern and also an include pattern' do
let(:settings) do
{ ignore_patterns: [/.*/], include_patterns: [/#{index_info['index']}/] }
end
it 'returns false' do
expect(curator).not_to be_should_ignore_index(index_info)
end
end
end
describe '#increment_index_name' do
......
......@@ -7,6 +7,7 @@
subject { described_class.new }
let(:curator) { ::Gitlab::Search::IndexCurator }
let(:settings) { described_class::CURATOR_SETTINGS }
let(:logger) { ::Gitlab::Elasticsearch::Logger.build }
describe '#perform' do
......@@ -15,7 +16,7 @@
end
it 'calls on the curator' do
expect(curator).to receive(:curate)
expect(curator).to receive(:curate).with(settings: settings)
expect(subject.perform).not_to be_falsey
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment