Add index_and_search_validation elastic rake task
What does this MR do and why?
This merge request improves the Elasticsearch upgrade process in GitLab by adding better validation and clearer documentation.
The main changes include:
-
Enhanced upgrade instructions: The documentation now provides clearer step-by-step guidance for upgrading Elasticsearch, including proper links to specific sections and a new validation step to ensure everything is working correctly after the upgrade.
-
New validation tool: A new command (
gitlab:elastic:index_and_search_validation
) has been added that administrators can run to verify that their Elasticsearch cluster is healthy and functioning properly. This helps catch issues early before resuming normal operations. -
Better user interface documentation: New sections explain how to enable/disable Elasticsearch search and pause/resume indexing through GitLab's admin interface, making these operations more accessible to administrators.
-
Improved logging: The validation service now accepts custom loggers, allowing better integration with different parts of the system and more flexible logging output.
-
Comprehensive testing: Extensive test coverage has been added to ensure the new validation functionality works reliably.
These changes make Elasticsearch upgrades safer and more user-friendly by providing administrators with better tools to validate their setup and clearer instructions to follow during the upgrade process.
References
Screenshots or screen recordings
Before | After |
---|---|
How to set up and validate locally
bundle exec rake gitlab:elastic:index_and_search_validation
- run the rake task (without elasticsearch setup for gdk if you'd like)
- setup gdk for elasticsearch
- run the rake task
Running index and search validation...
Index and search validation completed successfully
- set one of the indexes as read only
curl -X PUT "localhost:9200/gitlab-development-work_items/_settings" -H 'Content-Type: application/json' -d'
{
"index.blocks.write": true
}
'
- run the rake task
Running index and search validation...
An error occurred while validating search cluster (error_message: [403] {"error":{"root_cause":[{"type":"cluster_block_exception","reason":"index [gitlab-development-work_items-20250801-1921] blocked by: [FORBIDDEN/8/index write (api)];"}],"type":"cluster_block_exception","reason":"index [gitlab-development-work_items-20250801-1921] blocked by: [FORBIDDEN/8/index write (api)];"},"status":403}, error_class: Elasticsearch::Transport::Transport::Errors::Forbidden)
Index and search validation failed
- shutdown elasticsearch in gdk
gdk stop elasticsearch
- run the rake task
Running index and search validation...
The search cluster is unreachable
Index and search validation failed
NOTE: remember to undo the write block
curl -X PUT "localhost:9200/gitlab-development-work_items/_settings" -H 'Content-Type: application/json' -d'
{
"index.blocks.write": false
}
'
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.