Add application setting for elasticsearch retry on failure
What does this MR do and why?
Configure Elasticsearch Ruby client without ret... (!67273 - merged) set the number of retry on failures for Elasticsearch requests to 0 if ::Gitlab::CurrentSettings.elasticsearch_config[:retry_on_failure] is not set but we never added the retry_on_failure application setting. Some customers have asked for this setting in order to retry elasticsearch requests when they have failover hosts configured and this is also recommended by Elasticsearch docs:
This MR:
- Adds a new application setting called
elasticsearch_retry_on_failure- integer, default to0, not null, validation for>= 0 - Passes the setting to the Elasticsearch client builder so that every Elasticsearch request has this
retry_on_failureset (it's currently always set to 0) - Allows admins to set this setting on the search settings page
It closes Allow admin to configure Elasticsearch client r... (#337588 - closed) and part of Make sure we use retry_on_failure option for s... (#486935 - closed).
#486935 (closed) proposes to always set retry_on_failure to 1 for search requests only but that can be done separately.
Side note: we should consolidate all elasticsearch settings into one jsonb setting according to the developer docs. I created Consolidate elasticsearch application settings ... (#500267 - closed) for this.
Database review
This MR adds a migration to add a column to application_settings table.
-
✅ Migration reversable:upanddownmethods provided
db:gitlabcom-database-testing output: !169903 (comment 2170772690)
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.
Screenshots or screen recordings
Admin search settings page:
How to set up and validate locally
- On master, check that
Gitlab::Elastic::Helper.default.client.transport.transport.options[:retry_on_failure]is 0 - Checkout this branch
- Execute migration:
bundle exec rake db:migrate:up:main VERSION=20241021084712 - Check that
::Gitlab::CurrentSettings.elasticsearch_config[:retry_on_failure]is 0 - Check that
Gitlab::Elastic::Helper.default.client.transport.transport.options[:retry_on_failure]is 0 - Change the setting in the UI at http://localhost:3000/admin/application_settings/advanced_search
- Check that
::Gitlab::CurrentSettings.elasticsearch_config[:retry_on_failure]is changed - Check that
Gitlab::Elastic::Helper.default.client.transport.transport.options[:retry_on_failure]is changed - Undo migration:
bundle exec rake db:migrate:down:main VERSION=20241021084712
Related to #486935 (closed)

