Add preflight checks to resume_indexing rake task
What does this MR do and why?
The resume_indexing rake task now enforces the same validation checks as the web UI before allowing indexing to be resumed. This prevents users from bypassing important safeguards via the command line.
The rake task previously only checked whether indexing was paused before resuming it, without validating whether it was safe to do so. This could allow users to resume indexing in unsafe conditions (e.g., during a reindexing task or when a migration requires paused indexing), potentially causing data corruption or inconsistencies.
This MR adds three preflight checks to match the web UI behavior:
-
Check if indexing is enabled - Prevents resuming when
elasticsearch_indexingis disabled - Check for active reindexing tasks - Prevents resuming during an active reindex operation
- Check for running migrations requiring paused indexing - Prevents resuming when a migration needs indexing paused
Each validation failure logs a clear error message explaining why resuming cannot proceed.
References
Closes #587855 (closed)
Screenshots or screen recordings
N/A - This is a backend change to a rake task with no UI changes.
How to set up and validate locally
-
Enable Elasticsearch in your GDK and ensure indexing is paused:
ApplicationSetting.last.update!(elasticsearch_pause_indexing: true) -
Test validation when indexing is disabled:
ApplicationSetting.last.update!(elasticsearch_indexing: false)bundle exec rake gitlab:elastic:resume_indexingExpected output:
Cannot resume indexing: Indexing is disabled. Enable indexing first. -
Test validation when reindexing is in progress:
ApplicationSetting.last.update!(elasticsearch_indexing: true) Search::Elastic::ReindexingTask.create!bundle exec rake gitlab:elastic:resume_indexingExpected output:
Cannot resume indexing: A reindexing task is currently in progress. -
Test successful resume when all checks pass:
Search::Elastic::ReindexingTask.delete_all ApplicationSetting.last.update!(elasticsearch_indexing: true, elasticsearch_pause_indexing: true)bundle exec rake gitlab:elastic:resume_indexingExpected output:
Indexing is now running.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.