# HG changeset patch # User Balasankar 'Balu' C <balasankar@gitlab.com> # Date 1705003378 0 # Thu Jan 11 20:02:58 2024 +0000 # Node ID 86b2aea5704ced2676c483205c67844f44e6f4dd # Parent 11f4f203bc72c57c43488cdf48fe133a9a1f79cd Expose setting to specify config_command in GitLab Workhorse config file - Adds the `gitlab_workhorse['extra_config_command']` config option for gitlab.rb Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8363 Changelog: added Signed-off-by: Balasankar 'Balu' C <balasankar@gitlab.com> diff --git a/files/gitlab-config-template/gitlab.rb.template b/files/gitlab-config-template/gitlab.rb.template --- a/files/gitlab-config-template/gitlab.rb.template +++ b/files/gitlab-config-template/gitlab.rb.template @@ -1152,6 +1152,10 @@ # gitlab_workhorse['redis_sentinel_master_ip'] = nil # gitlab_workhorse['redis_sentinel_master_port'] = nil + +##! Command to generate extra configuration +# gitlab_workhorse['extra_config_command'] = nil + ################################################################################ ## GitLab User Settings ##! Modify default git user. diff --git a/files/gitlab-cookbooks/gitlab/attributes/default.rb b/files/gitlab-cookbooks/gitlab/attributes/default.rb --- a/files/gitlab-cookbooks/gitlab/attributes/default.rb +++ b/files/gitlab-cookbooks/gitlab/attributes/default.rb @@ -831,6 +831,8 @@ default['gitlab']['gitlab_workhorse']['redis_sentinel_master_ip'] = nil default['gitlab']['gitlab_workhorse']['redis_sentinel_master_port'] = nil +default['gitlab']['gitlab_workhorse']['extra_config_command'] = nil + #### # mailroom #### diff --git a/files/gitlab-cookbooks/gitlab/recipes/gitlab-workhorse.rb b/files/gitlab-cookbooks/gitlab/recipes/gitlab-workhorse.rb --- a/files/gitlab-cookbooks/gitlab/recipes/gitlab-workhorse.rb +++ b/files/gitlab-cookbooks/gitlab/recipes/gitlab-workhorse.rb @@ -95,6 +95,7 @@ image_scaler_max_filesize = node['gitlab']['gitlab_workhorse']['image_scaler_max_filesize'] trusted_cidrs_for_propagation = node['gitlab']['gitlab_workhorse']['trusted_cidrs_for_propagation'] trusted_cidrs_for_x_forwarded_for = node['gitlab']['gitlab_workhorse']['trusted_cidrs_for_x_forwarded_for'] +extra_config_command = node['gitlab']['gitlab_workhorse']['extra_config_command'] template config_file_path do source "workhorse-config.toml.erb" @@ -114,7 +115,8 @@ image_scaler_max_filesize: image_scaler_max_filesize, trusted_cidrs_for_propagation: trusted_cidrs_for_propagation, trusted_cidrs_for_x_forwarded_for: trusted_cidrs_for_x_forwarded_for, - object_store_toml: workhorse_helper.object_store_toml + object_store_toml: workhorse_helper.object_store_toml, + extra_config_command: extra_config_command ) notifies :restart, "runit_service[gitlab-workhorse]" notifies :run, 'bash[Set proper security context on ssh files for selinux]', :delayed if SELinuxHelper.enabled? diff --git a/files/gitlab-cookbooks/gitlab/templates/default/workhorse-config.toml.erb b/files/gitlab-cookbooks/gitlab/templates/default/workhorse-config.toml.erb --- a/files/gitlab-cookbooks/gitlab/templates/default/workhorse-config.toml.erb +++ b/files/gitlab-cookbooks/gitlab/templates/default/workhorse-config.toml.erb @@ -11,6 +11,10 @@ trusted_cidrs_for_x_forwarded_for = <%= @trusted_cidrs_for_x_forwarded_for.to_json %> <%- end %> +<%- if @extra_config_command %> +config_command = "<%= @extra_config_command %>" +<%- end %> + <% if @workhorse_keywatcher %> [redis] Password = "<%= @password %>" diff --git a/spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb b/spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb --- a/spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb +++ b/spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb @@ -60,6 +60,12 @@ expect(content).not_to match(/propagateCorrelationID/) } end + + it 'does not include config_command' do + expect(chef_run).to render_file(config_file).with_content { |content| + expect(content).not_to match(/config_command/) + } + end end context 'user and group' do @@ -765,5 +771,21 @@ end end + context 'with config_command specified' do + before do + stub_gitlab_rb( + gitlab_workhorse: { + extra_config_command: "/opt/workhorse-redis-config.sh" + } + ) + end + + it 'specifies config_command in the config file' do + expect(chef_run).to render_file(config_file).with_content { |content| + expect(content).to match(%r(config_command = "/opt/workhorse-redis-config.sh")) + } + end + end + include_examples "consul service discovery", "gitlab_workhorse", "workhorse" end