diff options
author | Lin Jen-Shin <godfat@godfat.org> | 2019-08-27 10:45:27 +0000 |
---|---|---|
committer | Lin Jen-Shin <godfat@godfat.org> | 2019-08-27 10:45:27 +0000 |
commit | f6d3a47bdea647c04178af4796da881d9fdfdd07 (patch) | |
tree | 45af3536d0733d9efae8bc25623e8146a9c1c376 | |
parent | 7efafa601f345e0a9f44639e77f8e5769e48d996 (diff) | |
parent | b99cf2024d1b518d876bc4f1f4aac8549b4dd993 (diff) | |
download | gitlab-ce-f6d3a47bdea647c04178af4796da881d9fdfdd07.tar.gz |
Merge branch '13806-fix' into 'master'
Add nil check for Gitlab.config.prometheus
Closes #13806
See merge request gitlab-org/gitlab-ce!32201
-rw-r--r-- | lib/gitlab/database_importers/self_monitoring/project/create_service.rb | 4 | ||||
-rw-r--r-- | spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb | 11 |
2 files changed, 13 insertions, 2 deletions
diff --git a/lib/gitlab/database_importers/self_monitoring/project/create_service.rb b/lib/gitlab/database_importers/self_monitoring/project/create_service.rb index 9387a76369f..3a170e8b5f8 100644 --- a/lib/gitlab/database_importers/self_monitoring/project/create_service.rb +++ b/lib/gitlab/database_importers/self_monitoring/project/create_service.rb @@ -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')) @@ -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')) diff --git a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb index 9bd0d800086..b25f0f6b887 100644 --- a/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb +++ b/spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb @@ -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 { |