Commit f434771f authored by rpereira2's avatar rpereira2

Expire the Gitlab::CurrentSettings cache

Expire the cache after it the self_monitoring_project_id is saved. This
is for the benefit of the later step where the Prometheus settings are
saved. When the Prometheus settings are saved, the PrometheusService
needs to be able to read the self_monitoring_project_id. If the cache
is not expired, PrometheusService will see the old value of the
self_monitoring_project_id. There is code in PrometheusService that
allows the self_monitoring_project to connect to the internal Prometheus
without needing local URLs to be allowed in webhooks.
parent ec46fc91
......@@ -74,6 +74,15 @@ module Gitlab
)
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)
else
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
expect(application_setting.self_monitoring_project_id).to eq(project.id)
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
expect(project.default_environment.name).to eq('production')
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