Commit 7fc536b5 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'expire-settings-cache-after-modifying' into 'master'

Expire the Gitlab::CurrentSettings cache

See merge request gitlab-org/gitlab!24710
parents fbf4d185 f434771f
...@@ -74,6 +74,15 @@ module Gitlab ...@@ -74,6 +74,15 @@ module Gitlab
) )
if response if response
# In the add_prometheus_manual_configuration method, the Prometheus
# listen_address config is saved as an api_url in the PrometheusService
# model. There are validates hooks in the PrometheusService model that
# check if the project associated with the PrometheusService is the
# self_monitoring project. It checks
# Gitlab::CurrentSettings.self_monitoring_project_id, which is why the
# Gitlab::CurrentSettings cache needs to be expired here, so that
# PrometheusService sees the latest self_monitoring_project_id.
Gitlab::CurrentSettings.expire_current_application_settings
success(result) success(result)
else else
log_error("Could not save instance administration project ID, errors: %{errors}" % { errors: application_settings.errors.full_messages }) log_error("Could not save instance administration project ID, errors: %{errors}" % { errors: application_settings.errors.full_messages })
......
...@@ -125,6 +125,11 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do ...@@ -125,6 +125,11 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do
expect(application_setting.self_monitoring_project_id).to eq(project.id) expect(application_setting.self_monitoring_project_id).to eq(project.id)
end end
it 'expires application_setting cache' do
expect(Gitlab::CurrentSettings).to receive(:expire_current_application_settings)
expect(result[:status]).to eq(:success)
end
it 'creates an environment for the project' do it 'creates an environment for the project' do
expect(project.default_environment.name).to eq('production') expect(project.default_environment.name).to eq('production')
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment