Commit 4679107f authored by Pawel Chojnacki's avatar Pawel Chojnacki

Handle case where GITLAB_PROMETHEUS_METRICS_ENABLED is non boolean value by defaulting to false

parent d26573c6
...@@ -20,7 +20,7 @@ end ...@@ -20,7 +20,7 @@ end
if ENV['GITLAB_PROMETHEUS_METRICS_ENABLED'].present? if ENV['GITLAB_PROMETHEUS_METRICS_ENABLED'].present?
settings = Gitlab::CurrentSettings.current_application_settings settings = Gitlab::CurrentSettings.current_application_settings
value = Gitlab::Utils.to_boolean(ENV['GITLAB_PROMETHEUS_METRICS_ENABLED']) value = Gitlab::Utils.to_boolean(ENV['GITLAB_PROMETHEUS_METRICS_ENABLED']) || false
settings.prometheus_metrics_enabled = value settings.prometheus_metrics_enabled = value
save(settings, 'Prometheus metrics enabled flag') save(settings, 'Prometheus metrics enabled flag')
end end
...@@ -42,5 +42,17 @@ describe 'seed production settings', lib: true do ...@@ -42,5 +42,17 @@ describe 'seed production settings', lib: true do
expect(settings.prometheus_metrics_enabled).to eq(false) expect(settings.prometheus_metrics_enabled).to eq(false)
end end
end end
context 'GITLAB_PROMETHEUS_METRICS_ENABLED is false' do
before do
stub_env('GITLAB_PROMETHEUS_METRICS_ENABLED', '')
end
it 'prometheus_metrics_enabled is set to false' do
load(settings_file)
expect(settings.prometheus_metrics_enabled).to eq(false)
end
end
end end
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