Skip to content

Commit c6941b7

Browse files
Robert Marshallashmckenzie
andcommitted
Merge branch 'ashmckenzie/add-metadata-settings-section-for-workhorse' into 'master'
Allow metadata zip reader limit to be configurable See merge request https://gitlab.com/gitlab-org/omnibus-gitlab/-/merge_requests/7410 Merged-by: Robert Marshall <[email protected]> Approved-by: Robert Marshall <[email protected]> Approved-by: João Alexandre Cunha <[email protected]> Co-authored-by: Ash McKenzie <[email protected]>
2 parents 310ee51 + f49b75e commit c6941b7

File tree

5 files changed

+37
-2
lines changed

5 files changed

+37
-2
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,10 +1162,12 @@ external_url 'GENERATED_EXTERNAL_URL'
11621162
# gitlab_workhorse['redis_sentinel_master_ip'] = nil
11631163
# gitlab_workhorse['redis_sentinel_master_port'] = nil
11641164

1165-
11661165
##! Command to generate extra configuration
11671166
# gitlab_workhorse['extra_config_command'] = nil
11681167

1168+
##! Metadata configuration section
1169+
# gitlab_workhorse['metadata_zip_reader_limit_bytes'] = nil
1170+
11691171
################################################################################
11701172
## GitLab User Settings
11711173
##! 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
@@ -848,6 +848,8 @@
848848

849849
default['gitlab']['gitlab_workhorse']['extra_config_command'] = nil
850850

851+
default['gitlab']['gitlab_workhorse']['metadata_zip_reader_limit_bytes'] = nil
852+
851853
####
852854
# mailroom
853855
####

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@
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']
9898
extra_config_command = node['gitlab']['gitlab_workhorse']['extra_config_command']
99+
metadata_zip_reader_limit_bytes = node['gitlab']['gitlab_workhorse']['metadata_zip_reader_limit_bytes']
99100

100101
template config_file_path do
101102
source "workhorse-config.toml.erb"
@@ -116,7 +117,8 @@
116117
trusted_cidrs_for_propagation: trusted_cidrs_for_propagation,
117118
trusted_cidrs_for_x_forwarded_for: trusted_cidrs_for_x_forwarded_for,
118119
object_store_toml: workhorse_helper.object_store_toml,
119-
extra_config_command: extra_config_command
120+
extra_config_command: extra_config_command,
121+
metadata_zip_reader_limit_bytes: metadata_zip_reader_limit_bytes
120122
)
121123
notifies :restart, "runit_service[gitlab-workhorse]"
122124
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,10 @@ SentinelPassword = "<%= @sentinel_password %>"
3434
[image_resizer]
3535
max_scaler_procs = <%= @image_scaler_max_procs %>
3636
max_filesize = <%= @image_scaler_max_filesize %>
37+
38+
<%- unless @metadata_zip_reader_limit_bytes.nil? %>
39+
[metadata]
40+
<%- if @metadata_zip_reader_limit_bytes %>
41+
zip_reader_limit_bytes = <%= @metadata_zip_reader_limit_bytes %>
42+
<%- end %>
43+
<%- end %>

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

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,12 @@
6666
expect(content).not_to match(/config_command/)
6767
}
6868
end
69+
70+
it 'does not include metadata section' do
71+
expect(chef_run).to render_file(config_file).with_content { |content|
72+
expect(content).not_to match(/\[metadata\]/)
73+
}
74+
end
6975
end
7076

7177
context 'user and group' do
@@ -787,5 +793,21 @@
787793
end
788794
end
789795

796+
context 'with metadata_zip_reader_limit_bytes specified' do
797+
before do
798+
stub_gitlab_rb(
799+
gitlab_workhorse: {
800+
metadata_zip_reader_limit_bytes: 209715200
801+
}
802+
)
803+
end
804+
805+
it 'specifies zip_reader_limit_bytes in the config file' do
806+
expect(chef_run).to render_file(config_file).with_content { |content|
807+
expect(content).to match(%r(\[metadata\]\n zip_reader_limit_bytes = 209715200))
808+
}
809+
end
810+
end
811+
790812
include_examples "consul service discovery", "gitlab_workhorse", "workhorse"
791813
end

0 commit comments

Comments
 (0)