Skip to content
Snippets Groups Projects
Commit 4250cd8b authored by Alessio Caiazza's avatar Alessio Caiazza
Browse files

Add gitaly graceful restart wrapper

parent 5ed01c99
No related branches found
No related tags found
No related merge requests found
---
title: Add gitaly graceful restart wrapper
merge_request: 3116
author:
type: added
......@@ -1603,6 +1603,7 @@
# gitaly['prometheus_grpc_latency_buckets'] = "[0.001, 0.005, 0.025, 0.1, 0.5, 1.0, 10.0, 30.0, 60.0, 300.0, 1500.0]"
# gitaly['auth_token'] = '<secret>'
# gitaly['auth_transitioning'] = false # When true, auth is logged to Prometheus but NOT enforced
# gitaly['graceful_restart_timeout'] = '1m' # Grace time for a gitaly process to finish ongoing requests
# gitaly['ruby_max_rss'] = 300000000 # RSS threshold in bytes for triggering a gitaly-ruby restart
# gitaly['ruby_graceful_restart_timeout'] = '10m' # Grace time for a gitaly-ruby process to finish ongoing requests
# gitaly['ruby_restart_delay'] = '5m' # Period of sustained high RSS that needs to be observed before restarting gitaly-ruby
......
......@@ -3,6 +3,7 @@
default['gitaly']['dir'] = "/var/opt/gitlab/gitaly"
default['gitaly']['log_directory'] = "/var/log/gitlab/gitaly"
default['gitaly']['env_directory'] = "/opt/gitlab/etc/gitaly/env"
default['gitaly']['graceful_restart_timeout'] = nil
# default['gitaly']['env'] is set in ../recipes/enable.rb
default['gitaly']['bin_path'] = "/opt/gitlab/embedded/bin/gitaly"
default['gitaly']['socket_path'] = "#{node['gitaly']['dir']}/gitaly.socket"
......
......@@ -20,6 +20,10 @@
log_directory = node['gitaly']['log_directory']
env_directory = node['gitaly']['env_directory']
config_path = File.join(working_dir, "config.toml")
gitaly_path = node['gitaly']['bin_path']
wrapper_path = "#{gitaly_path}-wrapper"
pid_file = File.join(working_dir, "gitaly.pid")
json_logging = node['gitaly']['logging_format'].eql?('json')
directory working_dir do
owner account_helper.gitlab_user
......@@ -47,8 +51,11 @@
# Charlock Holmes and libicu will report U_FILE_ACCESS_ERROR if this is not set to the right path
# See https://gitlab.com/gitlab-org/gitlab-ce/issues/17415#note_13868167
'ICU_DATA' => "#{node['package']['install-dir']}/embedded/share/icu/current",
'SSL_CERT_DIR' => "#{node['package']['install-dir']}/embedded/ssl/certs/"
'SSL_CERT_DIR' => "#{node['package']['install-dir']}/embedded/ssl/certs/",
# wrapper script parameters
'GITALY_PID_FILE' => pid_file,
'WRAPPER_JSON_LOGGING' => json_logging.to_s
}
env_dir env_directory do
variables node['gitaly']['env']
......@@ -51,8 +58,8 @@
}
env_dir env_directory do
variables node['gitaly']['env']
notifies :restart, "service[gitaly]"
notifies :hup, "runit_service[gitaly]"
end
# Before version 11.6, gitaly env directory was `/opt/gitlab/etc/gitaly` by
......@@ -73,7 +80,7 @@
group account_helper.gitlab_group
mode "0640"
variables node['gitaly'].to_hash
notifies :restart, "service[gitaly]"
notifies :hup, "runit_service[gitaly]"
end
runit_service 'gitaly' do
......@@ -83,5 +90,6 @@
groupname: account_helper.gitlab_group,
working_dir: working_dir,
env_dir: env_directory,
bin_path: node['gitaly']['bin_path'],
bin_path: gitaly_path,
wrapper_path: wrapper_path,
config_path: config_path,
......@@ -87,5 +95,6 @@
config_path: config_path,
log_directory: log_directory
log_directory: log_directory,
json_logging: json_logging
}.merge(params))
log_options node['gitlab']['logging'].to_hash.merge(node['gitaly'].to_hash)
end
......@@ -98,5 +107,5 @@
file File.join(working_dir, "VERSION") do
content VersionHelper.version("/opt/gitlab/embedded/bin/gitaly --version")
notifies :restart, "service[gitaly]"
notifies :hup, "runit_service[gitaly]"
end
......@@ -6,6 +6,9 @@
socket_path = '<%= @socket_path %>'
bin_dir = '/opt/gitlab/embedded/bin'
<% if @graceful_restart_timeout %>
graceful_restart_timeout = '<%= @graceful_restart_timeout %>'
<% end %>
<% if @listen_addr %>
# Optional: listen on a TCP socket. This is insecure (no authentication)
......
#!/bin/sh
exec svlogd <% unless node['gitaly']['logging_format'].eql?('json') %>-tt <% end %><%= @options[:log_directory] %>
exec svlogd <% unless @options[:json_logging] %>-tt <% end %><%= @options[:log_directory] %>
......@@ -11,4 +11,4 @@
exec chpst -e <%= @options[:env_dir] %> -P \
-U <%= @options[:user] %>:<%= @options[:groupname] %> \
-u <%= @options[:user] %>:<%= @options[:groupname] %> \
<%= @options[:bin_path] %> <%= @options[:config_path] %>
<%= @options[:wrapper_path] %> <%= @options[:bin_path] %> <%= @options[:config_path] %>
......@@ -34,6 +34,7 @@
'object-component', # MIT Licensed - https://github.com/component/object/blob/master/LICENSE
'select2', # MIT Licensed - https://github.com/select2/select2/blob/master/LICENSE.md
'exiftool', # License similar to Perl, which is under either GPL v1 or Artistic license - https://www.sno.phy.queensu.ca/~phil/exiftool/#license
'github.com/cloudflare/tableflip', # BSD-3-Clause Licensed - https://github.com/cloudflare/tableflip/blob/master/LICENSE
]
# readline is GPL licensed and its use was not mere aggregation. Hence it is
# blacklisted.
......
......@@ -20,6 +20,7 @@
let(:auth_token) { '123secret456' }
let(:auth_transitioning) { true }
let(:ruby_max_rss) { 1000000 }
let(:graceful_restart_timeout) { '20m' }
let(:ruby_graceful_restart_timeout) { '30m' }
let(:ruby_restart_delay) { '10m' }
let(:ruby_num_workers) { 5 }
......@@ -31,6 +32,8 @@
'PATH' => '/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/bin',
'ICU_DATA' => '/opt/gitlab/embedded/share/icu/current',
'PYTHONPATH' => '/opt/gitlab/embedded/lib/python3.4/site-packages',
'WRAPPER_JSON_LOGGING' => 'false',
"GITALY_PID_FILE" => '/var/opt/gitlab/gitaly/gitaly.pid',
}
end
......@@ -118,6 +121,7 @@
prometheus_grpc_latency_buckets: prometheus_grpc_latency_buckets,
auth_token: auth_token,
auth_transitioning: auth_transitioning,
graceful_restart_timeout: graceful_restart_timeout,
ruby_max_rss: ruby_max_rss,
ruby_graceful_restart_timeout: ruby_graceful_restart_timeout,
ruby_restart_delay: ruby_restart_delay,
......@@ -140,6 +144,8 @@
expect(chef_run).to render_file(config_path)
.with_content("listen_addr = 'localhost:7777'")
expect(chef_run).to render_file(config_path)
.with_content("graceful_restart_timeout = '#{graceful_restart_timeout}'")
expect(chef_run).to render_file(config_path)
.with_content { |content|
expect(content).to include("tls_listen_addr = 'localhost:8888'")
expect(content).to include("certificate_path = '/path/to/cert.pem'")
......
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