Skip to content
代码片段 群组 项目
提交 532a65fa 编辑于 作者: Madelein van Niekerk's avatar Madelein van Niekerk
浏览文件

Merge branch '431358-fix-reindexing-preflight-check' into 'master'

No related branches found
No related tags found
无相关合并请求
......@@ -61,7 +61,13 @@ def initial!
return false
end
expected_free_size = alias_names.sum { |name| elastic_helper.index_size_bytes(index_name: name) } * 2
target_classes = current_task.target_classes
current_size = target_classes.sum do |klass|
name = elastic_helper.klass_to_alias_name(klass: klass)
elastic_helper.index_size_bytes(index_name: name)
end
expected_free_size = current_size * 2
if elastic_helper.cluster_free_size_bytes < expected_free_size
abort_reindexing!("You should have at least #{expected_free_size} bytes of storage available to perform reindexing. Please increase the storage in your Elasticsearch cluster before reindexing.")
return false
......
......@@ -43,6 +43,18 @@
expect(Gitlab::CurrentSettings.elasticsearch_pause_indexing).to eq(true)
end
context 'when partial reindexing' do
let(:task) { create(:elastic_reindexing_task, state: :initial, targets: %w[Project User]) }
it 'errors when there is not enough space' do
allow(helper).to receive(:index_size_bytes).twice.and_return(10.megabytes)
allow(helper).to receive(:cluster_free_size_bytes).and_return(30.megabytes)
expect { cluster_reindexing_service.execute }.to change { task.reload.state }.from('initial').to('failure')
expect(task.reload.error_message).to match(/storage available/)
end
end
end
context 'state: indexing_paused' do
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册