Skip to content

Allow specifying single index to reindex when using reindex feature

Dmitry Gruzd requested to merge 323293-specify-single-index into master

What does this MR do and why?

This MR introduces a new field called targets to the elastic_reindexing_tasks table to allow reindexing specific indices using the Zero-downtime reindexing feature.

Screenshots or screen recordings

Screenshots are required for UI changes, and strongly recommended for all other merge requests.

Migrations

VERSION=20221006141145 bin/rails db:migrate:up:main
main: == 20221006141145 AddTargetsToElasticReindexingTasks: migrating ===============
main: -- add_column(:elastic_reindexing_tasks, :targets, :text, {:array=>true})
main:    -> 0.0012s
main: == 20221006141145 AddTargetsToElasticReindexingTasks: migrated (0.0014s) ======

VERSION=20221006141145 bin/rails db:migrate:down:main
main: == 20221006141145 AddTargetsToElasticReindexingTasks: reverting ===============
main: -- remove_column(:elastic_reindexing_tasks, :targets, :text, {:array=>true})
main:    -> 0.0022s
main: == 20221006141145 AddTargetsToElasticReindexingTasks: reverted (0.0041s) ======

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. Enable Advanced Search
  2. Create a new reindexing task with only one class. For example
    Elastic::ReindexingTask.create!(targets: %w[Repository])
  3. Trigger ElasticClusterReindexingCronWorker.new.perform repeatedly
  4. Check out the reindexing progress via Elastic::ReindexingTask.current or /admin/application_settings/advanced_search
  5. Ensure that you have a new gitlab-development index via curl http://localhost:9200/_cat/indices
  6. After reindexing is completed you should notice that Elastic::ReindexingTask.last.state has changed to success
  7. Ensure that curl http://localhost:9200/_cat/aliases/gitlab-development points to newly created index and search still works

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #323293 (closed)

Edited by Dmitry Gruzd

Merge request reports