Skip to content

Commit 7d56082

Browse files
author
Will Chandler
committed
Add 'use_wrapper' setting to Gitaly
Gitaly is in the process of implementing a write-ahead log (WAL) for git operations, which will provide significant benefits for resiliance and scalability. This model requires that we have only one Gitaly process running at a time. However, our current upgrade method keeps the old and new Gitaly processes running in parallel for an period of time defined by the administrator. The `gitaly-wrapper` binary is used by Omnibus to provide a stable pid to `runit` and sets the `GITALY_UPGRADES_ENABLED` environment variable that causes Gitaly to perform upgrades with concurrent processes. To prepare for the deployment of Gitaly's WAL architecture, add a new `gitaly['use_wrapper']` option which allows admins to execute Gitaly without the `gitaly-wrapper` binary so that there is never more than one Gitaly process running at once. This is enabled by default, admins must opt into the new behavior. Without the wrapper, sending SIGHUP to Gitaly will cause momentary service interruptions for git clone operations, ~300ms in our benchmarks. Read-only web requests will retry automatically for outages lasting up to 750ms and will handle the upgrade gracefully. We retain the wrapper for Praefect as this will remain compatible with running concurrent processes. Changelog: added
1 parent 5f15ec3 commit 7d56082

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2477,6 +2477,7 @@ external_url 'GENERATED_EXTERNAL_URL'
24772477
# gitaly['dir'] = "/var/opt/gitlab/gitaly"
24782478
# gitaly['log_group'] = nil
24792479
# gitaly['bin_path'] = "/opt/gitlab/embedded/bin/gitaly"
2480+
# gitaly['use_wrapper'] = true
24802481
# gitaly['env_directory'] = "/opt/gitlab/etc/gitaly/env"
24812482
# gitaly['env'] = {
24822483
# 'PATH' => "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/bin",

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
default['gitaly']['consul_service_name'] = 'gitaly'
99
default['gitaly']['consul_service_meta'] = nil
1010
default['gitaly']['log_group'] = nil
11+
default['gitaly']['use_wrapper'] = true
1112

1213
default['gitaly']['configuration'] = {
1314
runtime_dir: "#{node['gitaly']['dir']}/run",

files/gitlab-cookbooks/gitaly/recipes/enable.rb

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
runtime_dir = node.dig('gitaly', 'configuration', 'runtime_dir')
3131
cgroups_mountpoint = node.dig('gitaly', 'configuration', 'cgroups', 'mountpoint')
3232
cgroups_hierarchy_root = node.dig('gitaly', 'configuration', 'cgroups', 'hierarchy_root')
33+
use_wrapper = node['gitaly']['use_wrapper']
3334

3435
directory working_dir do
3536
owner account_helper.gitlab_user
@@ -145,6 +146,7 @@
145146
open_files_ulimit: open_files_ulimit,
146147
cgroups_mountpoint: cgroups_mountpoint,
147148
cgroups_hierarchy_root: cgroups_hierarchy_root,
149+
use_wrapper: use_wrapper,
148150
}.merge(params))
149151
log_options logging_settings[:options]
150152
end

files/gitlab-cookbooks/gitaly/templates/default/sv-gitaly-run.erb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,8 @@ cd <%= @options[:working_dir] %>
2424
exec chpst -e <%= @options[:env_dir] %> -P \
2525
-U <%= @options[:user] %>:<%= @options[:groupname] %> \
2626
-u <%= @options[:user] %>:<%= @options[:groupname] %> \
27+
<% if @options[:use_wrapper] %>
2728
<%= @options[:wrapper_path] %> <%= @options[:bin_path] %> <%= @options[:config_path] %>
29+
<% else %>
30+
<%= @options[:bin_path] %> <%= @options[:config_path] %>
31+
<% end %>

spec/chef/cookbooks/gitaly/recipes/gitaly_spec.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -698,6 +698,30 @@
698698
.with_content(/svlogd -tt \/var\/log\/gitlab\/gitaly/)
699699
end
700700

701+
context 'when use_wrapper is defined' do
702+
context 'with wrapper enabled' do
703+
before do
704+
stub_gitlab_rb(gitaly: { use_wrapper: true })
705+
end
706+
707+
it 'renders the runit run script with the wrapper' do
708+
expect(chef_run).to render_file('/opt/gitlab/sv/gitaly/run')
709+
.with_content(/\/opt\/gitlab\/embedded\/bin\/gitaly-wrapper/)
710+
end
711+
end
712+
713+
context 'with wrapper disabled' do
714+
before do
715+
stub_gitlab_rb(gitaly: { use_wrapper: false })
716+
end
717+
718+
it 'renders the runit run script without the wrapper' do
719+
expect(chef_run).not_to render_file('/opt/gitlab/sv/gitaly/run')
720+
.with_content(/\/opt\/gitlab\/embedded\/bin\/gitaly-wrapper/)
721+
end
722+
end
723+
end
724+
701725
context 'when using git_data_dirs storage configuration' do
702726
context 'using local gitaly' do
703727
before do

0 commit comments

Comments
 (0)