Commit 260c4a3f authored by Olena Horal-Koretska's avatar Olena Horal-Koretska

Merge branch...

Merge branch '321742-elasticsearch-index_exists-check-should-only-happen-when-changing-advanced-search-settings' into 'master'

Only check Elasticsearch index_exists? when changing Advanced Search settings

See merge request gitlab-org/gitlab!62135
parents 3850e498 1b36f9ab
...@@ -68,6 +68,11 @@ class Admin::ElasticsearchController < Admin::ApplicationController ...@@ -68,6 +68,11 @@ class Admin::ElasticsearchController < Admin::ApplicationController
end end
def trigger_reindexing_params 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
end end
...@@ -23,7 +23,7 @@ module EE ...@@ -23,7 +23,7 @@ module EE
elasticsearch_project_ids = params.delete(:elasticsearch_project_ids) elasticsearch_project_ids = params.delete(:elasticsearch_project_ids)
if result = super 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(ElasticsearchIndexedNamespace, elasticsearch_namespace_ids)
update_elasticsearch_containers(ElasticsearchIndexedProject, elasticsearch_project_ids) update_elasticsearch_containers(ElasticsearchIndexedProject, elasticsearch_project_ids)
update_elasticsearch_index_settings(number_of_replicas: elasticsearch_replicas, number_of_shards: elasticsearch_shards) update_elasticsearch_index_settings(number_of_replicas: elasticsearch_replicas, number_of_shards: elasticsearch_shards)
......
...@@ -239,7 +239,7 @@ ...@@ -239,7 +239,7 @@
%fieldset %fieldset
.form-group .form-group
= f.label :slice_multiplier, _('Slice multiplier'), class: 'label-bold' = 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 .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_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 } - slice_multiplier_link_start = '<a href="%{url}" target="_blank" rel="noopener noreferrer">'.html_safe % { url: slice_multiplier_link_url }
...@@ -247,7 +247,7 @@ ...@@ -247,7 +247,7 @@
.form-group .form-group
= f.label :max_slices_running, _('Maximum running slices'), class: 'label-bold' = 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 .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_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 } - 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 ...@@ -50,7 +50,7 @@ RSpec.describe Admin::ElasticsearchController do
expect(task).to receive(:save).and_return(true) expect(task).to receive(:save).and_return(true)
end 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(controller).to set_flash[:notice].to include('reindexing triggered')
expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing')
...@@ -59,14 +59,14 @@ RSpec.describe Admin::ElasticsearchController do ...@@ -59,14 +59,14 @@ RSpec.describe Admin::ElasticsearchController do
it 'does not create a reindexing task if there is another one' 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)) 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(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') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing')
end end
it 'does not create a reindexing task if a required param is nil' do 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(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') expect(response).to redirect_to advanced_search_admin_application_settings_path(anchor: 'js-elasticsearch-reindexing')
......
...@@ -63,6 +63,16 @@ RSpec.describe ApplicationSettings::UpdateService do ...@@ -63,6 +63,16 @@ RSpec.describe ApplicationSettings::UpdateService do
expect { service.execute }.not_to raise_error expect { service.execute }.not_to raise_error
end end
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
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