Skip to content

Commit c29d621

Browse files
Robert Marshallbalasankarc
andcommitted
Merge branch '8363-workhorse-external-config' into 'master'
Expose setting to specify config_command in GitLab Workhorse config file Closes https://gitlab.com/gitlab-org/omnibus-gitlab/-/issues/8363 See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7325 Merged-by: Robert Marshall <[email protected]> Approved-by: Andrew Patterson <[email protected]> Approved-by: Robert Marshall <[email protected]> Co-authored-by: Balasankar 'Balu' C <[email protected]>
2 parents 6e26777 + b6f13c7 commit c29d621

File tree

5 files changed

+35
-1
lines changed

5 files changed

+35
-1
lines changed

files/gitlab-config-template/gitlab.rb.template

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,10 @@ external_url 'GENERATED_EXTERNAL_URL'
11521152
# gitlab_workhorse['redis_sentinel_master_ip'] = nil
11531153
# gitlab_workhorse['redis_sentinel_master_port'] = nil
11541154

1155+
1156+
##! Command to generate extra configuration
1157+
# gitlab_workhorse['extra_config_command'] = nil
1158+
11551159
################################################################################
11561160
## GitLab User Settings
11571161
##! Modify default git user.

files/gitlab-cookbooks/gitlab/attributes/default.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -831,6 +831,8 @@
831831
default['gitlab']['gitlab_workhorse']['redis_sentinel_master_ip'] = nil
832832
default['gitlab']['gitlab_workhorse']['redis_sentinel_master_port'] = nil
833833

834+
default['gitlab']['gitlab_workhorse']['extra_config_command'] = nil
835+
834836
####
835837
# mailroom
836838
####

files/gitlab-cookbooks/gitlab/recipes/gitlab-workhorse.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@
9595
image_scaler_max_filesize = node['gitlab']['gitlab_workhorse']['image_scaler_max_filesize']
9696
trusted_cidrs_for_propagation = node['gitlab']['gitlab_workhorse']['trusted_cidrs_for_propagation']
9797
trusted_cidrs_for_x_forwarded_for = node['gitlab']['gitlab_workhorse']['trusted_cidrs_for_x_forwarded_for']
98+
extra_config_command = node['gitlab']['gitlab_workhorse']['extra_config_command']
9899

99100
template config_file_path do
100101
source "workhorse-config.toml.erb"
@@ -114,7 +115,8 @@
114115
image_scaler_max_filesize: image_scaler_max_filesize,
115116
trusted_cidrs_for_propagation: trusted_cidrs_for_propagation,
116117
trusted_cidrs_for_x_forwarded_for: trusted_cidrs_for_x_forwarded_for,
117-
object_store_toml: workhorse_helper.object_store_toml
118+
object_store_toml: workhorse_helper.object_store_toml,
119+
extra_config_command: extra_config_command
118120
)
119121
notifies :restart, "runit_service[gitlab-workhorse]"
120122
notifies :run, 'bash[Set proper security context on ssh files for selinux]', :delayed if SELinuxHelper.enabled?

files/gitlab-cookbooks/gitlab/templates/default/workhorse-config.toml.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ trusted_cidrs_for_propagation = <%= @trusted_cidrs_for_propagation.to_json %>
1111
trusted_cidrs_for_x_forwarded_for = <%= @trusted_cidrs_for_x_forwarded_for.to_json %>
1212
<%- end %>
1313

14+
<%- if @extra_config_command %>
15+
config_command = "<%= @extra_config_command %>"
16+
<%- end %>
17+
1418
<% if @workhorse_keywatcher %>
1519
[redis]
1620
Password = "<%= @password %>"

spec/chef/cookbooks/gitlab/recipes/gitlab-workhorse_spec.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,12 @@
6060
expect(content).not_to match(/propagateCorrelationID/)
6161
}
6262
end
63+
64+
it 'does not include config_command' do
65+
expect(chef_run).to render_file(config_file).with_content { |content|
66+
expect(content).not_to match(/config_command/)
67+
}
68+
end
6369
end
6470

6571
context 'user and group' do
@@ -765,5 +771,21 @@
765771
end
766772
end
767773

774+
context 'with config_command specified' do
775+
before do
776+
stub_gitlab_rb(
777+
gitlab_workhorse: {
778+
extra_config_command: "/opt/workhorse-redis-config.sh"
779+
}
780+
)
781+
end
782+
783+
it 'specifies config_command in the config file' do
784+
expect(chef_run).to render_file(config_file).with_content { |content|
785+
expect(content).to match(%r(config_command = "/opt/workhorse-redis-config.sh"))
786+
}
787+
end
788+
end
789+
768790
include_examples "consul service discovery", "gitlab_workhorse", "workhorse"
769791
end

0 commit comments

Comments
 (0)