Skip to content
Snippets Groups Projects
Commit f6d3a47b authored by Lin Jen-Shin's avatar Lin Jen-Shin
Browse files

Merge branch '13806-fix' into 'master'

Add nil check for Gitlab.config.prometheus

Closes #13806

See merge request gitlab-org/gitlab-ce!32201
parents 7efafa60 b99cf202
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -173,7 +173,7 @@ module Gitlab
end
 
def prometheus_enabled?
Gitlab.config.prometheus.enable
Gitlab.config.prometheus.enable if Gitlab.config.prometheus
rescue Settingslogic::MissingSetting
log_error(_('prometheus.enable is not present in gitlab.yml'))
 
Loading
Loading
@@ -181,7 +181,7 @@ module Gitlab
end
 
def prometheus_listen_address
Gitlab.config.prometheus.listen_address
Gitlab.config.prometheus.listen_address if Gitlab.config.prometheus
rescue Settingslogic::MissingSetting
log_error(_('prometheus.listen_address is not present in gitlab.yml'))
 
Loading
Loading
Loading
Loading
@@ -197,6 +197,17 @@ describe Gitlab::DatabaseImporters::SelfMonitoring::Project::CreateService do
end
end
 
context 'when prometheus setting is nil' do
before do
stub_config(prometheus: nil)
end
it 'does not fail' do
expect(result).to include(status: :success)
expect(project.prometheus_service).to be_nil
end
end
context 'when prometheus setting is disabled in gitlab.yml' do
let(:prometheus_settings) do
{
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment