# HG changeset patch # User Balasankar 'Balu' C <balasankar@gitlab.com> # Date 1677182503 0 # Thu Feb 23 20:01:43 2023 +0000 # Node ID 2352fde2f6b0ef50f0be715e08d9ae86fa7559d4 # Parent fda0cf9de1107f10bbc123787eb3a8406f2474cd Deprecate usage of node['monitoring']['redis-exporter'] in gitlab.rb Use node['monitoring']['redis_exporter'] to access Chef attributes corresponding to redis-exporter service. Related https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/6873 Changelog: deprecated Signed-off-by: Balasankar "Balu" C <balasankar@gitlab.com> diff --git a/files/gitlab-cookbooks/monitoring/attributes/default.rb b/files/gitlab-cookbooks/monitoring/attributes/default.rb --- a/files/gitlab-cookbooks/monitoring/attributes/default.rb +++ b/files/gitlab-cookbooks/monitoring/attributes/default.rb @@ -63,15 +63,15 @@ #### # Redis exporter ### -default['monitoring']['redis-exporter']['enable'] = false -default['monitoring']['redis-exporter']['log_directory'] = "/var/log/gitlab/redis-exporter" -default['monitoring']['redis-exporter']['env_directory'] = '/opt/gitlab/etc/redis-exporter/env' -default['monitoring']['redis-exporter']['env'] = { +default['monitoring']['redis_exporter']['enable'] = false +default['monitoring']['redis_exporter']['log_directory'] = "/var/log/gitlab/redis-exporter" +default['monitoring']['redis_exporter']['env_directory'] = '/opt/gitlab/etc/redis-exporter/env' +default['monitoring']['redis_exporter']['env'] = { 'SSL_CERT_DIR' => "#{node['package']['install-dir']}/embedded/ssl/certs/" } -default['monitoring']['redis-exporter']['listen_address'] = 'localhost:9121' -default['monitoring']['redis-exporter']['consul_service_name'] = 'redis-exporter' -default['monitoring']['redis-exporter']['consul_service_meta'] = nil +default['monitoring']['redis_exporter']['listen_address'] = 'localhost:9121' +default['monitoring']['redis_exporter']['consul_service_name'] = 'redis-exporter' +default['monitoring']['redis_exporter']['consul_service_meta'] = nil #### # Postgres exporter @@ -188,7 +188,8 @@ } default['monitoring']['grafana']['register_as_oauth_app'] = true -# Temporarily retain support for `node['monitoring']['node-exporter'][*]` usage in +# Temporarily retain support for `node['monitoring']['*-exporter'][*]` usage in # `/etc/gitlab/gitlab.rb` # TODO: Remove support in 16.0 default['monitoring']['node-exporter'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['monitoring']['node_exporter'].to_h }, "node['monitoring']['node-exporter']", "node['monitoring']['node_exporter']") +default['monitoring']['redis-exporter'] = Gitlab::Deprecations::NodeAttribute.new(proc { node['monitoring']['redis_exporter'].to_h }, "node['monitoring']['redis-exporter']", "node['monitoring']['redis_exporter']") diff --git a/files/gitlab-cookbooks/monitoring/libraries/prometheus.rb b/files/gitlab-cookbooks/monitoring/libraries/prometheus.rb --- a/files/gitlab-cookbooks/monitoring/libraries/prometheus.rb +++ b/files/gitlab-cookbooks/monitoring/libraries/prometheus.rb @@ -114,7 +114,7 @@ end def parse_redis_exporter_flags - default_config = Gitlab['node']['monitoring']['redis-exporter'].to_hash + default_config = Gitlab['node']['monitoring']['redis_exporter'].to_hash user_config = Gitlab['redis_exporter'] listen_address = user_config['listen_address'] || default_config['listen_address'] diff --git a/files/gitlab-cookbooks/monitoring/recipes/redis-exporter.rb b/files/gitlab-cookbooks/monitoring/recipes/redis-exporter.rb --- a/files/gitlab-cookbooks/monitoring/recipes/redis-exporter.rb +++ b/files/gitlab-cookbooks/monitoring/recipes/redis-exporter.rb @@ -17,8 +17,8 @@ # account_helper = AccountHelper.new(node) redis_user = account_helper.redis_user -redis_exporter_log_dir = node['monitoring']['redis-exporter']['log_directory'] -redis_exporter_static_etc_dir = node['monitoring']['redis-exporter']['env_directory'] +redis_exporter_log_dir = node['monitoring']['redis_exporter']['log_directory'] +redis_exporter_static_etc_dir = node['monitoring']['redis_exporter']['env_directory'] directory redis_exporter_log_dir do owner redis_user @@ -33,11 +33,11 @@ end env_dir redis_exporter_static_etc_dir do - variables node['monitoring']['redis-exporter']['env'] + variables node['monitoring']['redis_exporter']['env'] notifies :restart, "runit_service[redis-exporter]" end -runtime_flags = PrometheusHelper.new(node).flags('redis-exporter') +runtime_flags = PrometheusHelper.new(node).flags('redis_exporter') runit_service 'redis-exporter' do options({ log_directory: redis_exporter_log_dir, @@ -53,10 +53,10 @@ end end -consul_service node['monitoring']['redis-exporter']['consul_service_name'] do +consul_service node['monitoring']['redis_exporter']['consul_service_name'] do id 'redis-exporter' - meta node['monitoring']['redis-exporter']['consul_service_meta'] + meta node['monitoring']['redis_exporter']['consul_service_meta'] action Prometheus.service_discovery_action - socket_address node['monitoring']['redis-exporter']['listen_address'] + socket_address node['monitoring']['redis_exporter']['listen_address'] reload_service false unless Services.enabled?('consul') end diff --git a/files/gitlab-cookbooks/monitoring/recipes/redis-exporter_disable.rb b/files/gitlab-cookbooks/monitoring/recipes/redis-exporter_disable.rb --- a/files/gitlab-cookbooks/monitoring/recipes/redis-exporter_disable.rb +++ b/files/gitlab-cookbooks/monitoring/recipes/redis-exporter_disable.rb @@ -20,7 +20,7 @@ action :disable end -consul_service node['monitoring']['redis-exporter']['consul_service_name'] do +consul_service node['monitoring']['redis_exporter']['consul_service_name'] do id 'redis-exporer' action :delete reload_service false unless Services.enabled?('consul') diff --git a/files/gitlab-cookbooks/package/libraries/settings_dsl.rb b/files/gitlab-cookbooks/package/libraries/settings_dsl.rb --- a/files/gitlab-cookbooks/package/libraries/settings_dsl.rb +++ b/files/gitlab-cookbooks/package/libraries/settings_dsl.rb @@ -255,6 +255,7 @@ gitlab_pages gitlab_sshd node_exporter + redis_exporter ] return underscored_form(key) if skip_hyphenation.include?(underscored_form(key)) diff --git a/spec/chef/cookbooks/gitlab/recipes/config_spec.rb b/spec/chef/cookbooks/gitlab/recipes/config_spec.rb --- a/spec/chef/cookbooks/gitlab/recipes/config_spec.rb +++ b/spec/chef/cookbooks/gitlab/recipes/config_spec.rb @@ -71,7 +71,7 @@ expect(node['monitoring']['prometheus']['enable']).to eq true expect(node['monitoring']['alertmanager']['enable']).to eq true expect(node['monitoring']['node_exporter']['enable']).to eq true - expect(node['monitoring']['redis-exporter']['enable']).to eq true + expect(node['monitoring']['redis_exporter']['enable']).to eq true expect(node['logrotate']['enable']).to eq true expect(node['monitoring']['postgres-exporter']['enable']).to eq true end @@ -97,7 +97,7 @@ it 'only sentinel is enabled' do expect(node['gitlab']['sentinel']['enable']).to eq true expect(node['redis']['enable']).to eq false - expect(node['monitoring']['redis-exporter']['enable']).to eq false + expect(node['monitoring']['redis_exporter']['enable']).to eq false expect(node['monitoring']['node_exporter']['enable']).to eq true expect(node['logrotate']['enable']).to eq true end @@ -120,7 +120,7 @@ it 'redis and sentinel are enabled' do expect(node['gitlab']['sentinel']['enable']).to eq true expect(node['redis']['enable']).to eq true - expect(node['monitoring']['redis-exporter']['enable']).to eq true + expect(node['monitoring']['redis_exporter']['enable']).to eq true expect(node['monitoring']['node_exporter']['enable']).to eq true expect(node['logrotate']['enable']).to eq true end @@ -149,7 +149,7 @@ it 'only redis is enabled' do expect(node['gitlab']['sentinel']['enable']).to eq true expect(node['redis']['enable']).to eq true - expect(node['monitoring']['redis-exporter']['enable']).to eq true + expect(node['monitoring']['redis_exporter']['enable']).to eq true expect(node['monitoring']['node_exporter']['enable']).to eq true expect(node['logrotate']['enable']).to eq true end @@ -171,7 +171,7 @@ it 'only redis is enabled' do expect(node['redis']['enable']).to eq true expect(node['gitlab']['sentinel']['enable']).to eq false - expect(node['monitoring']['redis-exporter']['enable']).to eq true + expect(node['monitoring']['redis_exporter']['enable']).to eq true expect(node['monitoring']['node_exporter']['enable']).to eq true expect(node['logrotate']['enable']).to eq true end diff --git a/spec/chef/cookbooks/monitoring/libraries/prometheus_spec.rb b/spec/chef/cookbooks/monitoring/libraries/prometheus_spec.rb --- a/spec/chef/cookbooks/monitoring/libraries/prometheus_spec.rb +++ b/spec/chef/cookbooks/monitoring/libraries/prometheus_spec.rb @@ -9,7 +9,7 @@ alertmanager grafana node_exporter - redis-exporter + redis_exporter postgres-exporter gitlab-exporter )) diff --git a/spec/chef/cookbooks/monitoring/recipes/redis_exporter_spec.rb b/spec/chef/cookbooks/monitoring/recipes/redis_exporter_spec.rb --- a/spec/chef/cookbooks/monitoring/recipes/redis_exporter_spec.rb +++ b/spec/chef/cookbooks/monitoring/recipes/redis_exporter_spec.rb @@ -21,13 +21,13 @@ end it 'defaults the redis-exporter to being disabled' do - expect(node['monitoring']['redis-exporter']['enable']).to eq false + expect(node['monitoring']['redis_exporter']['enable']).to eq false end it 'allows redis-exporter to be explicitly enabled' do stub_gitlab_rb(redis_exporter: { enable: true }) - expect(node['monitoring']['redis-exporter']['enable']).to eq true + expect(node['monitoring']['redis_exporter']['enable']).to eq true end end diff --git a/spec/chef/cookbooks/package/libraries/config/services_spec.rb b/spec/chef/cookbooks/package/libraries/config/services_spec.rb --- a/spec/chef/cookbooks/package/libraries/config/services_spec.rb +++ b/spec/chef/cookbooks/package/libraries/config/services_spec.rb @@ -200,7 +200,7 @@ it 'sets the correct values' do Services.disable_group('redis') expect(node['redis']['enable']).to be false - expect(node['monitoring']['redis-exporter']['enable']).to be false + expect(node['monitoring']['redis_exporter']['enable']).to be false Services.enable_group('rails') expect(node['gitlab']['puma']['enable']).to be true @@ -216,7 +216,7 @@ Services.enable_group('monitoring') Services.disable_group('redis', except: 'monitoring') expect(node['redis']['enable']).to be false - expect(node['monitoring']['redis-exporter']['enable']).to be true + expect(node['monitoring']['redis_exporter']['enable']).to be true end end @@ -228,7 +228,7 @@ expect(node['postgresql']['enable']).to be false Services.enable_group('rails', 'monitoring') - expect(node['monitoring']['redis-exporter']['enable']).to be true + expect(node['monitoring']['redis_exporter']['enable']).to be true expect(node['gitlab']['puma']['enable']).to be true end @@ -238,7 +238,7 @@ expect(node['redis']['enable']).to be true expect(node['gitlab']['puma']['enable']).to be true expect(node['monitoring']['gitlab-exporter']['enable']).to be false - expect(node['monitoring']['redis-exporter']['enable']).to be false + expect(node['monitoring']['redis_exporter']['enable']).to be false Services.enable_group('postgres') Services.disable_group('redis', 'monitoring', except: 'postgres') @@ -250,7 +250,7 @@ it 'supports multiple exceptions' do Services.disable_group('redis', Services::SYSTEM_GROUP, include_system: true) Services.enable_group('rails', 'monitoring', except: ['redis', Services::SYSTEM_GROUP]) - expect(node['monitoring']['redis-exporter']['enable']).to be false + expect(node['monitoring']['redis_exporter']['enable']).to be false expect(node['monitoring']['node_exporter']['enable']).to be false expect(node['gitlab']['puma']['enable']).to be true @@ -301,7 +301,7 @@ Services.enable_group(Services::ALL_GROUPS, except: %w(redis rails)) expect(node['gitlab']['puma']['enable']).to be false expect(node['monitoring']['node_exporter']['enable']).to be true - expect(node['monitoring']['redis-exporter']['enable']).to be false + expect(node['monitoring']['redis_exporter']['enable']).to be false end it 'disables all others' do diff --git a/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb b/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb --- a/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb +++ b/spec/chef/cookbooks/package/libraries/settings_dsl_spec.rb @@ -28,7 +28,8 @@ [ %w[gitlab-pages gitlab_pages], %w[gitlab-sshd gitlab_sshd], - %w[node-exporter node_exporter] + %w[node-exporter node_exporter], + %w[redis-exporter redis_exporter] ].each do |input, output| expect(subject.sanitized_key(input)).to eq(output) end