Commit 1b36f9ab authored by Terri Chu's avatar Terri Chu Committed by Olena Horal-Koretska

Only check Elasticsearch index_exists? when changing Advanced Search settings

parent 0fc3ec38
......@@ -68,6 +68,11 @@ class Admin::ElasticsearchController < Admin::ApplicationController
end
def trigger_reindexing_params
params.require(:elastic_reindexing_task).permit(%i(max_slices_running slice_multiplier))
permitted_params = params.require(:elastic_reindexing_task).permit(:elasticsearch_max_slices_running, :elasticsearch_slice_multiplier)
trigger_reindexing_params = {}
trigger_reindexing_params[:max_slices_running] = permitted_params[:elasticsearch_max_slices_running] if permitted_params.has_key?(:elasticsearch_max_slices_running)
trigger_reindexing_params[:slice_multiplier] = permitted_params[:elasticsearch_slice_multiplier] if permitted_params.has_key?(:elasticsearch_slice_multiplier)
trigger_reindexing_params
end
end
......@@ -23,7 +23,7 @@ module EE
elasticsearch_project_ids = params.delete(:elasticsearch_project_ids)
if result = super
find_or_create_elasticsearch_index
find_or_create_elasticsearch_index if params.keys.any? { |key| key.to_s.start_with?('elasticsearch') }
update_elasticsearch_containers(ElasticsearchIndexedNamespace, elasticsearch_namespace_ids)
update_elasticsearch_containers(ElasticsearchIndexedProject, elasticsearch_project_ids)
update_elasticsearch_index_settings(number_of_replicas: elasticsearch_replicas, number_of_shards: elasticsearch_shards)
......
......@@ -239,7 +239,7 @@
%fieldset
.form-group
= f.label :slice_multiplier, _('Slice multiplier'), class: 'label-bold'
= f.number_field :slice_multiplier, class: 'form-control gl-form-input', value: @elasticsearch_reindexing_task.slice_multiplier
= f.number_field :elasticsearch_slice_multiplier, class: 'form-control gl-form-input', value: @elasticsearch_reindexing_task.slice_multiplier
.form-text.gl-text-gray-600.gl-mt-0
- slice_multiplier_link_url = help_page_path('integration/elasticsearch.md', anchor: 'slice-multiplier')
- slice_multiplier_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: slice_multiplier_link_url }
......@@ -247,7 +247,7 @@
.form-group
= f.label :max_slices_running, _('Maximum running slices'), class: 'label-bold'
= f.number_field :max_slices_running, class: 'form-control gl-form-input', value: @elasticsearch_reindexing_task.max_slices_running
= f.number_field :elasticsearch_max_slices_running, class: 'form-control gl-form-input', value: @elasticsearch_reindexing_task.max_slices_running
.form-text.gl-text-gray-600.gl-mt-0
- max_slices_running_link_url = help_page_path('integration/elasticsearch.md', anchor: 'maximum-running-slices')
- max_slices_running_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: max_slices_running_link_url }
......
---
title: Only check index status if modifying Advanced Search form
merge_request: 62135
author:
type: fixed
......@@ -50,7 +50,7 @@ RSpec.describe Admin::ElasticsearchController do
expect(task).to receive(:save).and_return(true)
end
post :trigger_reindexing, params: { elastic_reindexing_task: { max_slices_running: 60, slice_multiplier: 2 } }
post :trigger_reindexing, params: { elastic_reindexing_task: { elasticsearch_max_slices_running: 60, elasticsearch_slice_multiplier: 2 } }
expect(controller).to set_flash[:notice].to include('reindexing triggered')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing')
......@@ -59,14 +59,14 @@ RSpec.describe Admin::ElasticsearchController do
it 'does not create a reindexing task if there is another one' do
allow(Elastic::ReindexingTask).to receive(:current).and_return(build(:elastic_reindexing_task))
post :trigger_reindexing, params: { elastic_reindexing_task: { max_slices_running: 60, slice_multiplier: 2 } }
post :trigger_reindexing, params: { elastic_reindexing_task: { elasticsearch_max_slices_running: 60, elasticsearch_slice_multiplier: 2 } }
expect(controller).to set_flash[:warning].to include('already in progress')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing')
end
it 'does not create a reindexing task if a required param is nil' do
post :trigger_reindexing, params: { elastic_reindexing_task: { max_slices_running: nil, slice_multiplier: 2 } }
post :trigger_reindexing, params: { elastic_reindexing_task: { elasticsearch_max_slices_running: nil, elasticsearch_slice_multiplier: 2 } }
expect(controller).to set_flash[:alert].to include('Elasticsearch reindexing was not started')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing')
......
......@@ -63,6 +63,16 @@ RSpec.describe ApplicationSettings::UpdateService do
expect { service.execute }.not_to raise_error
end
end
context 'when modifying a non Advanced Search setting' do
let(:opts) { { repository_size_limit: '100' } }
it 'does not check index_exists' do
expect(helper).not_to receive(:create_empty_index)
service.execute
end
end
end
end
......
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