Skip to content

Handle recursion when creating ApplicationSettings

What does this MR do and why?

This forbids recursive creation of application settings objects.

This was seen when setting up multiple databases in the GCK an example loop is:

app/models/application_setting.rb:24:in `block in <class:ApplicationSetting>'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:84:in `encrypted_strategy'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:71:in `optional?'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:79:in `get_encrypted_token'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:117:in `token_set?'
app/models/concerns/token_authenticatable_strategies/base.rb:40:in `ensure_token'
app/models/concerns/token_authenticatable_strategies/encrypted.rb:38:in `ensure_token'
app/models/concerns/token_authenticatable.rb:49:in `block in add_authentication_token_field'
app/models/application_setting_implementation.rb:247:in `tap'
app/models/application_setting_implementation.rb:247:in `create_from_defaults'
app/models/application_setting.rb:660:in `block in create_from_defaults'
app/models/concerns/cross_database_modification.rb:99:in `transaction'
app/models/application_setting.rb:659:in `create_from_defaults'
lib/gitlab/current_settings.rb:71:in `uncached_application_settings'
lib/gitlab/current_settings.rb:42:in `ensure_application_settings!'
lib/gitlab/current_settings.rb:15:in `block in current_application_settings'
lib/gitlab/null_request_store.rb:34:in `fetch'
lib/gitlab/safe_request_store.rb:12:in `fetch'
lib/gitlab/current_settings.rb:15:in `current_application_settings'
lib/gitlab/current_settings.rb:32:in `method_missing'
lib/gitlab/metrics/prometheus.rb:98:in `prometheus_metrics_enabled_unmemoized'
lib/gitlab/metrics/prometheus.rb:24:in `block in prometheus_metrics_enabled?'
lib/gitlab/utils/strong_memoize.rb:30:in `strong_memoize'
lib/gitlab/metrics/prometheus.rb:23:in `prometheus_metrics_enabled?'
lib/gitlab/metrics/prometheus.rb:90:in `provide_metric'
lib/gitlab/metrics/prometheus.rb:81:in `safe_provide_metric'
lib/gitlab/metrics/prometheus.rb:47:in `counter'
lib/gitlab/instrumentation/redis_base.rb:82:in `instance_count_request'
lib/gitlab/instrumentation/redis_interceptor.rb:18:in `call'
lib/feature.rb:95:in `enabled?'

How to set up and validate locally

This was encountered during set up of the GCK for multiple databases. To verify this change, set up your development environment for multiple databases, and try to run development rake tasks, such as db:migrate.

MR acceptance checklist

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

  • I have evaluated the MR acceptance checklist for this MR.

Related to #355015 (closed)

Edited by Alex Kalderimis

Merge request reports