diff --git a/doc/integration/advanced_search/elasticsearch.md b/doc/integration/advanced_search/elasticsearch.md index ced5a250b09343dedf658792ed7cc198644ee7d0..10fc2607b324a19f5471fc0878b3847ebee7c024 100644 --- a/doc/integration/advanced_search/elasticsearch.md +++ b/doc/integration/advanced_search/elasticsearch.md @@ -771,7 +771,7 @@ The following are some available Rake tasks: | Task | Description | |:--------------------------------------------------------------------------------------------------------------------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | [`sudo gitlab-rake gitlab:elastic:info`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/tasks/gitlab/elastic.rake) | Outputs debugging information for the advanced search integration. | -| [`sudo gitlab-rake gitlab:elastic:index`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/tasks/gitlab/elastic.rake) | In GitLab 17.0 and earlier, enables Elasticsearch indexing and runs `gitlab:elastic:recreate_index`, `gitlab:elastic:clear_index_status`, `gitlab:elastic:index_group_entities`, `gitlab:elastic:index_projects`, `gitlab:elastic:index_snippets`, and `gitlab:elastic:index_users`.<br>In GitLab 17.1 and later, queues a Sidekiq job in the background. First, the job enables Elasticsearch indexing and pauses indexing to ensure all indices are created. Then, the job re-creates all indices, clears indexing status, and queues additional Sidekiq jobs to index project and group data, snippets, and users. Finally, Elasticsearch indexing is resumed to complete. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/421298) in GitLab 17.1 [with a flag](../../administration/feature_flags.md) named `elastic_index_use_trigger_indexing`. Enabled by default. | +| [`sudo gitlab-rake gitlab:elastic:index`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/tasks/gitlab/elastic.rake) | In GitLab 17.0 and earlier, enables Elasticsearch indexing and runs `gitlab:elastic:recreate_index`, `gitlab:elastic:clear_index_status`, `gitlab:elastic:index_group_entities`, `gitlab:elastic:index_projects`, `gitlab:elastic:index_snippets`, and `gitlab:elastic:index_users`.<br>In GitLab 17.1 and later, queues a Sidekiq job in the background. First, the job enables Elasticsearch indexing and pauses indexing to ensure all indices are created. Then, the job re-creates all indices, clears indexing status, and queues additional Sidekiq jobs to index project and group data, snippets, and users. Finally, Elasticsearch indexing is resumed to complete. [Introduced](https://gitlab.com/gitlab-org/gitlab/-/issues/421298) in GitLab 17.1 [with a flag](../../administration/feature_flags.md) named `elastic_index_use_trigger_indexing`. Enabled by default. [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/434580) in GitLab 17.3. Feature flag `elastic_index_use_trigger_indexing` removed. | | [`sudo gitlab-rake gitlab:elastic:pause_indexing`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/tasks/gitlab/elastic.rake) | Pauses Elasticsearch indexing. Changes are still tracked. Useful for cluster/index migrations. | | [`sudo gitlab-rake gitlab:elastic:resume_indexing`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/tasks/gitlab/elastic.rake) | Resumes Elasticsearch indexing. | | [`sudo gitlab-rake gitlab:elastic:index_projects`](https://gitlab.com/gitlab-org/gitlab/-/blob/master/ee/lib/tasks/gitlab/elastic.rake) | Iterates over all projects, and queues Sidekiq jobs to index them in the background. It can only be used after the index is created. | diff --git a/ee/config/feature_flags/beta/elastic_index_use_trigger_indexing.yml b/ee/config/feature_flags/beta/elastic_index_use_trigger_indexing.yml deleted file mode 100644 index 5ca3437831786b5adef9d0e151ce2b1818ab459f..0000000000000000000000000000000000000000 --- a/ee/config/feature_flags/beta/elastic_index_use_trigger_indexing.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -name: elastic_index_use_trigger_indexing -feature_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/434590 -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/139300 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/434580 -milestone: '16.8' -group: group::global search -type: beta -default_enabled: false diff --git a/ee/lib/tasks/gitlab/elastic.rake b/ee/lib/tasks/gitlab/elastic.rake index 2161c5f3f432e56c401023b916ede1f48141e577..43f525c9daa585dcdbd70f94d32b8ab48f9ea017 100644 --- a/ee/lib/tasks/gitlab/elastic.rake +++ b/ee/lib/tasks/gitlab/elastic.rake @@ -6,50 +6,23 @@ namespace :gitlab do task index: :environment do raise 'This task cannot be run on GitLab.com' if ::Gitlab::Saas.feature_available?(:advanced_search) - if Feature.enabled?(:elastic_index_use_trigger_indexing) # rubocop:disable Gitlab/FeatureFlagWithoutActor -- this ff cannot have an actor - if ::Gitlab::CurrentSettings.elasticsearch_pause_indexing? - stdout_logger.warn('WARNING: `elasticsearch_pause_indexing` is enabled. ' \ - 'This setting will be disabled to complete indexing'.color(:yellow)) - end - - unless Gitlab::CurrentSettings.elasticsearch_indexing? - stdout_logger.warn('Setting `elasticsearch_indexing` is disabled. ' \ - 'This setting will been enabled to complete indexing.'.color(:yellow)) - end - - stdout_logger.info('Scheduling indexing with TriggerIndexingWorker') - - # skip projects, all namespace and project data is handled by `namespaces` task - Search::Elastic::TriggerIndexingWorker.perform_in(1.minute, - Search::Elastic::TriggerIndexingWorker::INITIAL_TASK, { 'skip' => 'projects' }) - - stdout_logger.info("Scheduling indexing with TriggerIndexingWorker... #{'done'.color(:green)}") - else - # enable `elasticsearch_indexing` if it isn't - unless Gitlab::CurrentSettings.elasticsearch_indexing? - ApplicationSettings::UpdateService.new( - Gitlab::CurrentSettings.current_application_settings, - nil, - { elasticsearch_indexing: true } - ).execute + if ::Gitlab::CurrentSettings.elasticsearch_pause_indexing? + stdout_logger.warn('WARNING: `elasticsearch_pause_indexing` is enabled. ' \ + 'This setting will be disabled to complete indexing'.color(:yellow)) + end - stdout_logger.info('Setting `elasticsearch_indexing` has been enabled.') - end + unless Gitlab::CurrentSettings.elasticsearch_indexing? + stdout_logger.warn('Setting `elasticsearch_indexing` is disabled. ' \ + 'This setting will been enabled to complete indexing.'.color(:yellow)) + end - if ::Gitlab::CurrentSettings.elasticsearch_pause_indexing? - stdout_logger.warn('WARNING: `elasticsearch_pause_indexing` is enabled. ' \ - 'Disable this setting by running `rake gitlab:elastic:resume_indexing` ' \ - 'to complete indexing.'.color(:yellow)) - end + stdout_logger.info('Scheduling indexing with TriggerIndexingWorker') - Rake::Task['gitlab:elastic:recreate_index'].invoke - Rake::Task['gitlab:elastic:clear_index_status'].invoke + # skip projects, all namespace and project data is handled by `namespaces` task + Search::Elastic::TriggerIndexingWorker.perform_in(1.minute, + Search::Elastic::TriggerIndexingWorker::INITIAL_TASK, { 'skip' => 'projects' }) - Rake::Task['gitlab:elastic:index_group_entities'].invoke - Rake::Task['gitlab:elastic:index_projects'].invoke - Rake::Task['gitlab:elastic:index_snippets'].invoke - Rake::Task['gitlab:elastic:index_users'].invoke - end + stdout_logger.info("Scheduling indexing with TriggerIndexingWorker... #{'done'.color(:green)}") end desc 'GitLab | Elasticsearch | Index Group entities' diff --git a/ee/spec/tasks/gitlab/elastic_rake_spec.rb b/ee/spec/tasks/gitlab/elastic_rake_spec.rb index 60f372854425be153c707b95f9c3196c2d02c1fb..7260ca06e6fc6dcb9b78c510cd7c6e0805803f8c 100644 --- a/ee/spec/tasks/gitlab/elastic_rake_spec.rb +++ b/ee/spec/tasks/gitlab/elastic_rake_spec.rb @@ -116,28 +116,10 @@ end context 'with elasticsearch_indexing is disabled' do - context 'when elastic_index_use_trigger_indexing is enabled' do - before do - stub_feature_flags(elastic_index_use_trigger_indexing: true) - end - - it 'does not enable `elasticsearch_indexing`' do - expect { run_rake_task 'gitlab:elastic:index' }.not_to change { - Gitlab::CurrentSettings.elasticsearch_indexing? - } - end - end - - context 'when elastic_index_use_trigger_indexing is disabled' do - before do - stub_feature_flags(elastic_index_use_trigger_indexing: false) - end - - it 'enables `elasticsearch_indexing`' do - expect { run_rake_task 'gitlab:elastic:index' }.to change { - Gitlab::CurrentSettings.elasticsearch_indexing? - }.from(false).to(true) - end + it 'does not enable `elasticsearch_indexing`' do + expect { run_rake_task 'gitlab:elastic:index' }.not_to change { + Gitlab::CurrentSettings.elasticsearch_indexing? + } end end @@ -168,37 +150,6 @@ task end - - context 'when elastic_index_use_trigger_indexing is disabled' do - before do - stub_feature_flags(elastic_index_use_trigger_indexing: false) - end - - it 'calls all indexing tasks in order' do - expect(Rake::Task['gitlab:elastic:recreate_index']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:clear_index_status']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_group_entities']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_projects']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_snippets']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_users']).to receive(:invoke).ordered - - task - end - - it 'outputs warning if indexing is paused and still runs all indexing tasks in order' do - stub_ee_application_setting(elasticsearch_pause_indexing: true) - - expect(Rake::Task['gitlab:elastic:recreate_index']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:clear_index_status']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_group_entities']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_projects']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_snippets']).to receive(:invoke).ordered - expect(Rake::Task['gitlab:elastic:index_users']).to receive(:invoke).ordered - expect(logger).to receive(:warn).with(/WARNING: `elasticsearch_pause_indexing` is enabled/) - - task - end - end end end end