diff --git a/files/gitlab-config-template/gitlab.rb.template b/files/gitlab-config-template/gitlab.rb.template index fc0ca7ecc5be939cd35139749cc0ce5b93614ed9_ZmlsZXMvZ2l0bGFiLWNvbmZpZy10ZW1wbGF0ZS9naXRsYWIucmIudGVtcGxhdGU=..ac954dbed5580bdd2aa70e2a93c12503b8e18d5f_ZmlsZXMvZ2l0bGFiLWNvbmZpZy10ZW1wbGF0ZS9naXRsYWIucmIudGVtcGxhdGU= 100644 --- a/files/gitlab-config-template/gitlab.rb.template +++ b/files/gitlab-config-template/gitlab.rb.template @@ -1060,5 +1060,4 @@ ##! Specifies where health-check endpoints should be made available for Sidekiq processes. ##! Defaults to the same settings as for Prometheus metrics (see above). # sidekiq['health_checks_enabled'] = true -# sidekiq['health_checks_log_enabled'] = false # sidekiq['health_checks_listen_address'] = "localhost" @@ -1064,5 +1063,5 @@ # sidekiq['health_checks_listen_address'] = "localhost" -# sidekiq['health_checks_listen_port'] = 8082 +# sidekiq['health_checks_listen_port'] = 8092 ##! Service name used to register Sidekiq as a Consul service # sidekiq['consul_service_name'] = 'sidekiq' diff --git a/files/gitlab-cookbooks/gitlab/attributes/default.rb b/files/gitlab-cookbooks/gitlab/attributes/default.rb index fc0ca7ecc5be939cd35139749cc0ce5b93614ed9_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvYXR0cmlidXRlcy9kZWZhdWx0LnJi..ac954dbed5580bdd2aa70e2a93c12503b8e18d5f_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvYXR0cmlidXRlcy9kZWZhdWx0LnJi 100644 --- a/files/gitlab-cookbooks/gitlab/attributes/default.rb +++ b/files/gitlab-cookbooks/gitlab/attributes/default.rb @@ -583,10 +583,9 @@ default['gitlab']['sidekiq']['listen_port'] = 8082 # Sidekiq health-check server defaults -default['gitlab']['sidekiq']['health_checks_enabled'] = nil -default['gitlab']['sidekiq']['health_checks_log_enabled'] = nil -default['gitlab']['sidekiq']['health_checks_listen_address'] = nil -default['gitlab']['sidekiq']['health_checks_listen_port'] = nil +default['gitlab']['sidekiq']['health_checks_enabled'] = true +default['gitlab']['sidekiq']['health_checks_listen_address'] = "127.0.0.1" +default['gitlab']['sidekiq']['health_checks_listen_port'] = 8092 # Cluster specific settings default['gitlab']['sidekiq']['queue_selector'] = false diff --git a/files/gitlab-cookbooks/gitlab/libraries/sidekiq.rb b/files/gitlab-cookbooks/gitlab/libraries/sidekiq.rb index fc0ca7ecc5be939cd35139749cc0ce5b93614ed9_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvbGlicmFyaWVzL3NpZGVraXEucmI=..ac954dbed5580bdd2aa70e2a93c12503b8e18d5f_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvbGlicmFyaWVzL3NpZGVraXEucmI= 100644 --- a/files/gitlab-cookbooks/gitlab/libraries/sidekiq.rb +++ b/files/gitlab-cookbooks/gitlab/libraries/sidekiq.rb @@ -1,3 +1,6 @@ +require 'resolv' +require 'ipaddr' + module Sidekiq class << self def parse_variables @@ -5,9 +8,6 @@ end def check_listen_address - # TODO: In %15.0 we want to change this deprecation log to raise an error instead - # See: https://gitlab.com/gitlab-org/gitlab/-/issues/350148 - default_config = Gitlab['node']['gitlab']['sidekiq'] user_config = Gitlab['sidekiq'] @@ -18,7 +18,16 @@ return if listen_address.nil? || health_checks_address.nil? - LoggingHelper.deprecation("Sidekiq exporter and health checks are set to the same address and port. This is deprecated and will result in an error in version 15.0. See https://docs.gitlab.com/ee/administration/sidekiq.html") if listen_address == health_checks_address && listen_port == health_checks_port + raise "The Sidekiq metrics and health checks servers are binding the same address and port. This is unsupported in GitLab 15.0 and newer. See https://docs.gitlab.com/ee/administration/sidekiq.html for up-to-date instructions." if same_address?(listen_address, health_checks_address) && listen_port == health_checks_port + end + + private + + def same_address?(address1, address2) + addr1 = IPAddr.new(Resolv.getaddress(address1)) + addr2 = IPAddr.new(Resolv.getaddress(address2)) + + addr1.loopback? == addr2.loopback? || addr1 == addr2 end end end diff --git a/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb b/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb index fc0ca7ecc5be939cd35139749cc0ce5b93614ed9_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvdGVtcGxhdGVzL2RlZmF1bHQvZ2l0bGFiLnltbC5lcmI=..ac954dbed5580bdd2aa70e2a93c12503b8e18d5f_ZmlsZXMvZ2l0bGFiLWNvb2tib29rcy9naXRsYWIvdGVtcGxhdGVzL2RlZmF1bHQvZ2l0bGFiLnltbC5lcmI= 100644 --- a/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/gitlab.yml.erb @@ -1008,10 +1008,9 @@ # Sidekiq health checks is a webserver built in to Sidekiq to serve health checks for the workers sidekiq_health_checks: - enabled: <%= @sidekiq['health_checks_enabled'].nil? ? @sidekiq['metrics_enabled'] : @sidekiq['health_checks_enabled'] %> - log_enabled: <%= @sidekiq['health_checks_log_enabled'].nil? ? @sidekiq['exporter_log_enabled'] : @sidekiq['health_checks_log_enabled'] %> - address: <%= @sidekiq['health_checks_listen_address'].nil? ? @sidekiq['listen_address'] : @sidekiq['health_checks_listen_address'] %> - port: <%= @sidekiq['health_checks_listen_port'].nil? ? @sidekiq['listen_port'] : @sidekiq['health_checks_listen_port'] %> + enabled: <%= @sidekiq['health_checks_enabled'] %> + address: <%= @sidekiq['health_checks_listen_address'] %> + port: <%= @sidekiq['health_checks_listen_port'] %> # Web exporter is webserver built in to Unicorn/Puma to expose Prometheus metrics web_exporter: diff --git a/spec/chef/cookbooks/gitlab/recipes/default_spec.rb b/spec/chef/cookbooks/gitlab/recipes/default_spec.rb index fc0ca7ecc5be939cd35139749cc0ce5b93614ed9_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9kZWZhdWx0X3NwZWMucmI=..ac954dbed5580bdd2aa70e2a93c12503b8e18d5f_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9kZWZhdWx0X3NwZWMucmI= 100644 --- a/spec/chef/cookbooks/gitlab/recipes/default_spec.rb +++ b/spec/chef/cookbooks/gitlab/recipes/default_spec.rb @@ -137,6 +137,26 @@ end context 'with sidekiq exporter settings' do + context 'when Sidekiq exporter and Sidekiq health checks addresses are both loopback addresses and the ports are the same' do + before do + stub_gitlab_rb( + sidekiq: + { + metrics_enabled: true, + listen_address: 'localhost', + listen_port: 3807, + health_checks_enabled: true, + health_checks_listen_address: '127.0.0.1', + health_checks_listen_port: 3807 + } + ) + end + + it 'raises an error' do + expect { chef_run }.to raise_error("The Sidekiq metrics and health checks servers are binding the same address and port. This is unsupported in GitLab 15.0 and newer. See https://docs.gitlab.com/ee/administration/sidekiq.html for up-to-date instructions.") + end + end + context 'when Sidekiq exporter and Sidekiq health checks port are the same' do before do stub_gitlab_rb( @@ -152,11 +172,8 @@ ) end - it 'logs a warning' do - allow(LoggingHelper).to receive(:deprecation) - expect(LoggingHelper).to receive(:deprecation).with("Sidekiq exporter and health checks are set to the same address and port. This is deprecated and will result in an error in version 15.0. See https://docs.gitlab.com/ee/administration/sidekiq.html") - - chef_run + it 'raises an error' do + expect { chef_run }.to raise_error("The Sidekiq metrics and health checks servers are binding the same address and port. This is unsupported in GitLab 15.0 and newer. See https://docs.gitlab.com/ee/administration/sidekiq.html for up-to-date instructions.") end end @@ -175,12 +192,10 @@ ) end - it 'does not log a warning' do - expect(LoggingHelper).not_to receive(:deprecation).with("Sidekiq exporter and health checks are set to the same address and port. This is deprecated and will result in an error in version 15.0. See https://docs.gitlab.com/ee/administration/sidekiq.html") - - chef_run + it 'does not raise an error' do + expect { chef_run }.not_to raise_error end end end context 'with sidekiq exporter settings not set (default settings)' do @@ -182,12 +197,10 @@ end end end context 'with sidekiq exporter settings not set (default settings)' do - it 'does not log a warning' do - expect(LoggingHelper).not_to receive(:deprecation).with("Sidekiq exporter and health checks are set to the same address and port. This is deprecated and will result in an error in version 15.0. See https://docs.gitlab.com/ee/administration/sidekiq.html") - - chef_run + it 'does not raise an error' do + expect { chef_run }.not_to raise_error end end end diff --git a/spec/chef/cookbooks/gitlab/recipes/gitlab-rails/gitlab_yml/monitoring_spec.rb b/spec/chef/cookbooks/gitlab/recipes/gitlab-rails/gitlab_yml/monitoring_spec.rb index fc0ca7ecc5be939cd35139749cc0ce5b93614ed9_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9naXRsYWItcmFpbHMvZ2l0bGFiX3ltbC9tb25pdG9yaW5nX3NwZWMucmI=..ac954dbed5580bdd2aa70e2a93c12503b8e18d5f_c3BlYy9jaGVmL2Nvb2tib29rcy9naXRsYWIvcmVjaXBlcy9naXRsYWItcmFpbHMvZ2l0bGFiX3ltbC9tb25pdG9yaW5nX3NwZWMucmI= 100644 --- a/spec/chef/cookbooks/gitlab/recipes/gitlab-rails/gitlab_yml/monitoring_spec.rb +++ b/spec/chef/cookbooks/gitlab/recipes/gitlab-rails/gitlab_yml/monitoring_spec.rb @@ -16,8 +16,7 @@ }, sidekiq_health_checks: { enabled: true, - log_enabled: false, - port: 8082, + port: 8092, address: '127.0.0.1' }, web_exporter: { @@ -83,5 +82,5 @@ context 'when health-checks are not configured manually' do let(:health_checks_settings) { {} } - it 'defaults health-checks to exporter settings' do + it 'uses the default settings' do expect(gitlab_yml[:production][:monitoring][:sidekiq_health_checks]).to eq( @@ -87,8 +86,7 @@ expect(gitlab_yml[:production][:monitoring][:sidekiq_health_checks]).to eq( - enabled: false, - log_enabled: true, - port: 2222, - address: '1.2.2.2' + enabled: true, + port: 8092, + address: '127.0.0.1' ) end end @@ -98,7 +96,6 @@ { sidekiq: { health_checks_enabled: true, - health_checks_log_enabled: true, health_checks_listen_address: '1.2.3.5', health_checks_listen_port: 1235 } @@ -108,7 +105,6 @@ it 'uses custom health-checks settings' do expect(gitlab_yml[:production][:monitoring][:sidekiq_health_checks]).to eq( enabled: true, - log_enabled: true, port: 1235, address: '1.2.3.5' )