Commit d82412f4 authored by Mark Chao's avatar Mark Chao

Add web UI to trigger full indexing

Indexing done in background job
parent 5603e23a
# frozen_string_literal: true
class Admin::ElasticsearchController < Admin::ApplicationController
before_action :check_elasticsearch_web_indexing_feature_flag!
def check_elasticsearch_web_indexing_feature_flag!
render_404 unless Feature.enabled?(:elasticsearch_web_indexing)
end
# POST
# Scheduling indexing jobs
def enqueue_index
::Elastic::IndexProjectsService.new.execute
notice = _('Elasticsearch indexing started')
queue_link = helpers.link_to(_('(check progress)'), sidekiq_path + '/queues/elastic_full_index')
flash[:notice] = "#{notice} #{queue_link}".html_safe
redirect_back_or_default
end
end
......@@ -82,3 +82,11 @@
AWS Secret Access Key. Only required if not using role instance credentials
= f.submit 'Save changes', class: "btn btn-success"
- if Feature.enabled?(:elasticsearch_web_indexing)
%br
%h4
= _('Indexing')
= form_with url: admin_elasticsearch_enqueue_index_path, html: { class: 'fieldset-form' }, data: { remote: false } do |f|
= f.submit _('Start Indexing'), class: "btn btn-success"
---
title: Allowing Elasticsearch indexing gap recovering
merge_request: 11408
author:
type: changed
......@@ -44,5 +44,9 @@ namespace :admin do
resources :uploads, only: [:index, :destroy]
end
namespace :elasticsearch do
post :enqueue_index
end
get '/dashboard/stats', to: 'dashboard#stats'
end
# frozen_string_literal: true
require 'spec_helper'
describe Admin::ElasticsearchController do
let(:admin) { create(:admin) }
describe 'POST #enqueue_index' do
before do
sign_in(admin)
end
it 'starts indexing' do
expect_next_instance_of(::Elastic::IndexProjectsService) do |service|
expect(service).to receive(:execute)
end
post :enqueue_index
expect(controller).to set_flash[:notice].to include('/admin/sidekiq/queues/elastic_full_index')
end
context 'when feature disabled' do
it 'does nothing and returns 404' do
stub_feature_flags(elasticsearch_web_indexing: false)
expect(::Elastic::IndexProjectsService).not_to receive(:new)
post :enqueue_index
expect(response).to have_gitlab_http_status(404)
end
end
end
end
......@@ -306,6 +306,9 @@ msgstr ""
msgid "(No changes)"
msgstr ""
msgid "(check progress)"
msgstr ""
msgid "(external source)"
msgstr ""
......@@ -4271,6 +4274,9 @@ msgstr ""
msgid "Elasticsearch"
msgstr ""
msgid "Elasticsearch indexing started"
msgstr ""
msgid "Elasticsearch integration. Elasticsearch AWS IAM."
msgstr ""
......@@ -6606,6 +6612,9 @@ msgstr ""
msgid "Incompatible options set!"
msgstr ""
msgid "Indexing"
msgstr ""
msgid "Indicates whether this runner can pick jobs without tags"
msgstr ""
......@@ -11534,6 +11543,9 @@ msgstr ""
msgid "Start GitLab Ultimate trial"
msgstr ""
msgid "Start Indexing"
msgstr ""
msgid "Start Web Terminal"
msgstr ""
......
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