Merge branch 'fix-exporter-disable' into 'master'

Fix regression from 9.0.1 where you can no longer explicitely disable postgres or redis exporters

Closes #2162

See merge request !1435
This commit is contained in:
Marin Jankovski 2017-04-03 10:16:03 +00:00
commit 04eaf7f618
2 changed files with 46 additions and 2 deletions

View File

@ -37,8 +37,8 @@ module Prometheus
def parse_exporter_enabled
# Disable exporters by default if their service is not managed on this node
Gitlab['postgres_exporter']['enable'] ||= Postgresql.postgresql_managed?
Gitlab['redis_exporter']['enable'] ||= Redis.redis_managed?
Gitlab['postgres_exporter']['enable'] = Postgresql.postgresql_managed? if Gitlab['postgres_exporter']['enable'].nil?
Gitlab['redis_exporter']['enable'] = Redis.redis_managed? if Gitlab['redis_exporter']['enable'].nil?
end
def parse_flags

View File

@ -112,6 +112,50 @@ describe 'gitlab::prometheus' do
end
end
context 'when redis and postgres are disabled' do
before do
stub_gitlab_rb(
postgresql: {
enable: false
},
redis: {
enable: false
}
)
end
context 'and user did not enable the exporter' do
it 'postgres exporter is disabled' do
expect(chef_run).to_not include_recipe('gitlab::postgres-exporter')
end
it 'redis exporter is disabled' do
expect(chef_run).to_not include_recipe('gitlab::redis-exporter')
end
end
context 'and user enabled the exporter' do
before do
stub_gitlab_rb(
postgres_exporter: {
enable: true
},
redis_exporter: {
enable: true
}
)
end
it 'postgres exporter is enabled' do
expect(chef_run).to include_recipe('gitlab::postgres-exporter')
end
it 'redis exporter is enabled' do
expect(chef_run).to include_recipe('gitlab::redis-exporter')
end
end
end
context 'with user provided settings' do
before do
stub_gitlab_rb(