Merge branch 'workhorse-api-limits' into 'master'

Add support for configuring workhorse's api limiting

Fixes: https://gitlab.com/gitlab-org/omnibus-gitlab/issues/1613

MR in workhorse for the setting went in here: https://gitlab.com/gitlab-org/gitlab-workhorse/merge_requests/65

cc\ @ayufan

See merge request !1020
This commit is contained in:
Marin Jankovski 2016-10-06 12:22:26 +00:00
commit 1b6c85d473
5 changed files with 36 additions and 0 deletions

View File

@ -6,6 +6,7 @@ omnibus-gitlab repository.
8.13.0
- Add support for registry debug addr configuration
- Add support for configuring workhorse's api limiting
- Support specifying a post reconfigure script to run in the docker container
- Updated cacerts.pem to 2016-09-14 version

View File

@ -396,6 +396,9 @@ external_url 'GENERATED_EXTERNAL_URL'
# gitlab_workhorse['dir'] = "/var/opt/gitlab/gitlab-workhorse"
# gitlab_workhorse['log_directory'] = "/var/log/gitlab/gitlab-workhorse"
# gitlab_workhorse['proxy_headers_timeout'] = "1m0s"
# gitlab_workhorse['api_limit'] = 0 # limit number of concurrent API requests, defaults to 0 which is unlimited
# gitlab_workhorse['api_queue_limit'] = 0 # limit number of API requests allowed to be queued, defaults to 0 which disables queuing
# gitlab_workhorse['api_queue_duration'] = "30s" # duration after which we timeout requests if they sit too long in the queue
# gitlab_workhorse['env'] = {
# 'PATH' => "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/bin"
# }

View File

@ -456,6 +456,9 @@ default['gitlab']['gitlab-workhorse']['pprof_listen_addr'] = "''" # put an empty
default['gitlab']['gitlab-workhorse']['dir'] = "/var/opt/gitlab/gitlab-workhorse"
default['gitlab']['gitlab-workhorse']['log_directory'] = "/var/log/gitlab/gitlab-workhorse"
default['gitlab']['gitlab-workhorse']['proxy_headers_timeout'] = nil
default['gitlab']['gitlab-workhorse']['api_limit'] = nil
default['gitlab']['gitlab-workhorse']['api_queue_duration'] = nil
default['gitlab']['gitlab-workhorse']['api_queue_limit'] = nil
default['gitlab']['gitlab-workhorse']['env'] = {
'PATH' => "#{node['package']['install-dir']}/bin:#{node['package']['install-dir']}/embedded/bin:/bin:/usr/bin",
'HOME' => node['gitlab']['user']['home']

View File

@ -22,6 +22,15 @@ exec chpst -e /opt/gitlab/etc/gitlab-workhorse/env -P \
<% if node['gitlab']['gitlab-workhorse']['proxy_headers_timeout'] %>
-proxyHeadersTimeout <%= node['gitlab']['gitlab-workhorse']['proxy_headers_timeout'] %> \
<% end %>
<% if node['gitlab']['gitlab-workhorse']['api_limit'] %>
-apiLimit <%= node['gitlab']['gitlab-workhorse']['api_limit'] %> \
<% end %>
<% if node['gitlab']['gitlab-workhorse']['api_queue_duration'] %>
-apiQueueDuration <%= node['gitlab']['gitlab-workhorse']['api_queue_duration'] %> \
<% end %>
<% if node['gitlab']['gitlab-workhorse']['api_queue_limit'] %>
-apiQueueLimit <%= node['gitlab']['gitlab-workhorse']['api_queue_limit'] %> \
<% end %>
-secretPath /opt/gitlab/embedded/service/gitlab-rails/.gitlab_workhorse_secret \
# Do not remove this line; it prevents trouble with the trailing backslashes above.

View File

@ -25,4 +25,24 @@ describe 'gitlab::gitlab-workhorse' do
end
end
end
context 'without api rate limiting' do
it 'correctly renders out the workhorse service file' do
expect(chef_run).to_not render_file("/opt/gitlab/sv/gitlab-workhorse/run").with_content(/\-apiLimit/)
expect(chef_run).to_not render_file("/opt/gitlab/sv/gitlab-workhorse/run").with_content(/\-apiQueueDuration/)
expect(chef_run).to_not render_file("/opt/gitlab/sv/gitlab-workhorse/run").with_content(/\-apiQueueLimit/)
end
end
context 'with api rate limiting' do
before do
stub_gitlab_rb(gitlab_workhorse: { api_limit: 3, api_queue_limit: 6, api_queue_duration: '1m' })
end
it 'correctly renders out the workhorse service file' do
expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-workhorse/run").with_content(/\-apiLimit 3 \\/)
expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-workhorse/run").with_content(/\-apiQueueDuration 1m \\/)
expect(chef_run).to render_file("/opt/gitlab/sv/gitlab-workhorse/run").with_content(/\-apiQueueLimit 6 \\/)
end
end
end