api: Add Elasticsearch index settings retrieval to application settings
What does this MR do and why?
This change introduces the ability to retrieve Elasticsearch index settings via the application settings API endpoint (GET /api/v4/application/settings). This is necessary to provide users with access to the configuration of Elasticsearch indices, which is essential for managing search capabilities and ensuring deterministic configuration management.
Technical changes:
- Added
elasticsearch_index_settingsmethod to theApplicationSettingmodel that returns ordered index settings via theElastic::IndexSetting.order_by_namescope - Created a new Grape API entity
API::Entities::Elastic::IndexSettingto expose index attributes with proper documentation:-
alias_name- Name of the Elasticsearch index alias -
number_of_shards- Number of shards for the Elasticsearch index -
number_of_replicas- Number of replicas for the Elasticsearch index
-
- Updated the application setting API entity to include the new index settings in the response when the
elastic_searchlicense feature is available
Example API response:
{
"elasticsearch_index_settings": [
{
"alias_name": "gitlab-production",
"number_of_shards": 5,
"number_of_replicas": 1
}
]
}
References
- Related to GitLab issue: #571263
Screenshots or screen recordings
Not applicable - API-only change with no UI modifications.
How to set up and validate locally
- Enable the Elasticsearch feature license in your development environment
- Create some Elasticsearch index settings in the database:
# In rails console Elastic::IndexSetting.create!(alias_name: 'test-index', number_of_shards: 5, number_of_replicas: 1) - Make an API request to retrieve application settings:
curl --header "PRIVATE-TOKEN: <your_access_token>" \ "http://localhost:3000/api/v4/application/settings" | jq '.elasticsearch_index_settings' - Verify the response includes the
elasticsearch_index_settingsarray with the expected structure
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
MR Checklist (@gerardo-navarro)
- Changelog entry added, if necessary
- Documentation created/updated via this MR
- Documentation reviewed by technical writer or follow-up review issue created
- Tests added for this feature/bug
- Tested in all supported browsers - N/A (API only)
- Conforms to the code review guidelines
- Conforms to the style guides
- Conforms to the javascript style guides - N/A (no JS changes)
- Conforms to the database guides - N/A (no database migrations)
- Conforms to the merge request performance guidelines
- API entity includes proper documentation for OpenAPI spec generation
-
License feature check ensures the setting is only exposed when
elastic_searchfeature is available