Skip to content
Snippets Groups Projects
Commit 37d18e38 authored by Matthias Käppler's avatar Matthias Käppler :bicyclist_tone5:
Browse files

Allow users to configure workhorse image scaler

parent 3d01873e
No related branches found
No related tags found
No related merge requests found
Loading
Loading
@@ -821,6 +821,15 @@ gitlab_rails['object_store']['objects']['terraform_state']['bucket'] = nil
# 'SSL_CERT_DIR' => "/opt/gitlab/embedded/ssl/certs/"
# }
 
##! Resource limitations for the dynamic image scaler.
##! Exceeding these thresholds will cause Workhorse to serve images in their original size.
##!
##! Maximum number of scaler processes that are allowed to execute before new requests are rejected
# gitlab_workhorse['image_scaler_max_procs'] = 50
##!
##! Maximum file size in bytes for an image to be considered eligible for rescaling
# gitlab_workhorse['image_scaler_max_filesize'] = 250000
################################################################################
## GitLab User Settings
##! Modify default git user.
Loading
Loading
Loading
Loading
@@ -631,6 +631,8 @@ default['gitlab']['gitlab-workhorse']['env'] = {
'HOME' => node['gitlab']['user']['home'],
'SSL_CERT_DIR' => "#{node['package']['install-dir']}/embedded/ssl/certs/"
}
default['gitlab']['gitlab-workhorse']['image_scaler_max_procs'] = 100
default['gitlab']['gitlab-workhorse']['image_scaler_max_filesize'] = 250_000
 
####
# mailroom
Loading
Loading
Loading
Loading
@@ -75,12 +75,24 @@ config_file_path = File.join(working_dir, "config.toml")
object_store = node['gitlab']['gitlab-rails']['object_store']
provider = object_store.dig('connection', 'provider')
object_store_provider = provider if %w(AWS AzureRM).include?(provider)
image_scaler_max_procs = node['gitlab']['gitlab-workhorse']['image_scaler_max_procs']
image_scaler_max_filesize = node['gitlab']['gitlab-workhorse']['image_scaler_max_filesize']
 
template config_file_path do
source "workhorse-config.toml.erb"
owner "root"
group account_helper.gitlab_group
mode "0640"
variables(object_store: object_store, object_store_provider: object_store_provider, redis_url: redis_url, password: redis_password, sentinels: redis_sentinels, sentinel_master: redis_sentinel_master, master_password: redis_sentinel_master_password)
variables(
object_store: object_store,
object_store_provider: object_store_provider,
redis_url: redis_url,
password: redis_password,
sentinels: redis_sentinels,
sentinel_master: redis_sentinel_master,
master_password: redis_sentinel_master_password,
image_scaler_max_procs: image_scaler_max_procs,
image_scaler_max_filesize: image_scaler_max_filesize
)
notifies :restart, "runit_service[gitlab-workhorse]"
end
Loading
Loading
@@ -24,5 +24,5 @@ Password = "<%= @master_password %>"
<%- end %>
 
[image_resizer]
max_scaler_procs = 100
max_filesize = 250000
max_scaler_procs = <%= @image_scaler_max_procs %>
max_filesize = <%= @image_scaler_max_filesize %>
Loading
Loading
@@ -398,4 +398,31 @@ RSpec.describe 'gitlab::gitlab-workhorse' do
expect(chef_run).not_to render_file("/var/opt/gitlab/gitlab-workhorse/config.toml").with_content(content_url)
end
end
context 'image scaler' do
context 'with default values' do
it 'should generate config file with the default values' do
expect(chef_run).to render_file(config_file).with_content { |content|
expect(content).to match(/\[image_resizer\]\n max_scaler_procs = 100\n max_filesize = 250000/m)
}
end
end
context 'with custom values' do
before do
stub_gitlab_rb(
gitlab_workhorse: {
image_scaler_max_procs: 5,
image_scaler_max_filesize: 1024
}
)
end
it 'should generate config file with the specified values' do
expect(chef_run).to render_file(config_file).with_content { |content|
expect(content).to match(/\[image_resizer\]\n max_scaler_procs = 5\n max_filesize = 1024/m)
}
end
end
end
end
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment