Merge branch 'feature/gitaly-config-file' into 'master'
Supply configuration file for Gitaly Closes #2185 See merge request !1454
This commit is contained in:
commit
7c7c7287de
|
@ -6,6 +6,7 @@ omnibus-gitlab repository.
|
|||
9.1.0
|
||||
|
||||
- Remove deprecated satellites configuration
|
||||
- Add configuration file for Gitaly
|
||||
|
||||
9.0.4
|
||||
|
||||
|
|
|
@ -1353,9 +1353,11 @@ external_url 'GENERATED_EXTERNAL_URL'
|
|||
# gitaly['env_directory'] = "/opt/gitlab/etc/gitaly"
|
||||
# gitaly['env'] = {
|
||||
# 'PATH' => "/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/bin",
|
||||
# 'HOME' => '/var/opt/gitlab',
|
||||
# 'GITALY_SOCKET_PATH' => "/var/opt/gitlab/gitaly/gitaly.socket"
|
||||
# 'HOME' => '/var/opt/gitlab'
|
||||
# }
|
||||
# gitaly['socket_path'] = "/var/opt/gitlab/gitaly/gitaly.socket"
|
||||
# gitaly['listen_addr'] = "localhost:8075"
|
||||
# gitaly['prometheus_listen_addr'] = "localhost:9175"
|
||||
|
||||
|
||||
################################################################################
|
||||
|
|
|
@ -461,22 +461,6 @@ default['gitlab']['web-server']['home'] = '/var/opt/gitlab/nginx'
|
|||
# When bundled nginx is disabled we need to add the external webserver user to the GitLab webserver group
|
||||
default['gitlab']['web-server']['external_users'] = []
|
||||
|
||||
|
||||
####
|
||||
# gitaly
|
||||
####
|
||||
default['gitlab']['gitaly']['enable'] = true
|
||||
default['gitlab']['gitaly']['ha'] = false
|
||||
default['gitlab']['gitaly']['dir'] = "/var/opt/gitlab/gitaly"
|
||||
default['gitlab']['gitaly']['log_directory'] = "/var/log/gitlab/gitaly"
|
||||
default['gitlab']['gitaly']['bin_path'] = "/opt/gitlab/embedded/bin/gitaly"
|
||||
default['gitlab']['gitaly']['env_directory'] = "/opt/gitlab/etc/gitaly"
|
||||
default['gitlab']['gitaly']['env'] = {
|
||||
'PATH' => "#{node['package']['install-dir']}/bin:#{node['package']['install-dir']}/embedded/bin:/bin:/usr/bin",
|
||||
'HOME' => node['gitlab']['user']['home'],
|
||||
'GITALY_SOCKET_PATH' => "#{node['gitlab']['gitaly']['dir']}/gitaly.socket"
|
||||
}
|
||||
|
||||
####
|
||||
# gitlab-workhorse
|
||||
####
|
||||
|
@ -944,3 +928,20 @@ default['gitlab']['gitlab-monitor']['listen_port'] = '9168'
|
|||
|
||||
# To completely disable prometheus, and all of it's exporters, set to false
|
||||
default['gitlab']['prometheus-monitoring']['enable'] = true
|
||||
|
||||
####
|
||||
# Gitaly
|
||||
####
|
||||
default['gitlab']['gitaly']['enable'] = true
|
||||
default['gitlab']['gitaly']['ha'] = false
|
||||
default['gitlab']['gitaly']['dir'] = "/var/opt/gitlab/gitaly"
|
||||
default['gitlab']['gitaly']['log_directory'] = "/var/log/gitlab/gitaly"
|
||||
default['gitlab']['gitaly']['env_directory'] = "/opt/gitlab/etc/gitaly"
|
||||
default['gitlab']['gitaly']['env'] = {
|
||||
'PATH' => "#{node['package']['install-dir']}/bin:#{node['package']['install-dir']}/embedded/bin:/bin:/usr/bin",
|
||||
'HOME' => node['gitlab']['user']['home']
|
||||
}
|
||||
default['gitlab']['gitaly']['bin_path'] = "/opt/gitlab/embedded/bin/gitaly"
|
||||
default['gitlab']['gitaly']['socket_path'] = "#{node['gitlab']['gitaly']['dir']}/gitaly.socket"
|
||||
default['gitlab']['gitaly']['listen_addr'] = nil
|
||||
default['gitlab']['gitaly']['prometheus_listen_addr'] = nil
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#
|
||||
# Copyright:: Copyright (c) 2016 GitLab B.V.
|
||||
# Copyright:: Copyright (c) 2017 GitLab Inc.
|
||||
# License:: Apache License, Version 2.0
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
|
@ -19,6 +19,7 @@ account_helper = AccountHelper.new(node)
|
|||
working_dir = node['gitlab']['gitaly']['dir']
|
||||
log_directory = node['gitlab']['gitaly']['log_directory']
|
||||
env_directory = node['gitlab']['gitaly']['env_directory']
|
||||
config_path = File.join(working_dir, "config.toml")
|
||||
|
||||
directory working_dir do
|
||||
owner account_helper.gitlab_user
|
||||
|
@ -37,10 +38,25 @@ env_dir env_directory do
|
|||
restarts ["service[gitaly]"]
|
||||
end
|
||||
|
||||
template "Create Gitaly config.toml" do
|
||||
path config_path
|
||||
source "gitaly-config.toml.erb"
|
||||
owner "root"
|
||||
group "root"
|
||||
mode "0644"
|
||||
variables node['gitlab']['gitaly'].to_hash
|
||||
notifies :restart, "service[gitaly]"
|
||||
end
|
||||
|
||||
runit_service 'gitaly' do
|
||||
down node['gitlab']['gitaly']['ha']
|
||||
options({
|
||||
:log_directory => log_directory
|
||||
user: account_helper.gitlab_user,
|
||||
working_dir: working_dir,
|
||||
env_dir: env_directory,
|
||||
bin_path: node['gitlab']['gitaly']['bin_path'],
|
||||
config_path: config_path,
|
||||
log_directory: log_directory
|
||||
}.merge(params))
|
||||
log_options node['gitlab']['logging'].to_hash.merge(node['gitlab']['gitaly'].to_hash)
|
||||
end
|
||||
|
|
|
@ -227,7 +227,7 @@ templatesymlink "Create a relative_url.rb and create a symlink to Rails root" do
|
|||
end
|
||||
end
|
||||
|
||||
gitaly_socket = node['gitlab']['gitaly']['env']['GITALY_SOCKET_PATH'] if node['gitlab']['gitaly']['enable']
|
||||
gitaly_socket = node['gitlab']['gitaly']['socket_path'] if node['gitlab']['gitaly']['enable']
|
||||
|
||||
templatesymlink "Create a gitlab.yml and create a symlink to Rails root" do
|
||||
link_from File.join(gitlab_rails_source_dir, "config/gitlab.yml")
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
# Gitaly configuration file
|
||||
# This file is managed by gitlab-ctl. Manual changes will be
|
||||
# erased! To change the contents below, edit /etc/gitlab/gitlab.rb
|
||||
# and run:
|
||||
# sudo gitlab-ctl reconfigure
|
||||
|
||||
socket_path = '<%= @socket_path %>'
|
||||
|
||||
<% if @listen_addr %>
|
||||
# Optional: listen on a TCP socket. This is insecure (no authentication)
|
||||
listen_addr = '<%= @listen_addr %>'
|
||||
<% end %>
|
||||
|
||||
<% if @prometheus_listen_addr %>
|
||||
# Optional: export metrics via Prometheus
|
||||
prometheus_listen_addr = '<%= @prometheus_listen_addr %>'
|
||||
<% end %>
|
||||
|
||||
# [[storage]]
|
||||
# name = "default"
|
||||
# path = "/home/git/repositories"
|
||||
|
||||
# # You can optionally configure more storages for this Gitaly instance to serve up
|
||||
#
|
||||
# [[storage]]
|
||||
# name = "other_storage"
|
||||
# path = "/mnt/other_storage/repositories"
|
|
@ -6,9 +6,9 @@ exec 2>&1
|
|||
|
||||
<%= render("mount_point_check.erb") %>
|
||||
|
||||
cd <%= node['gitlab']['gitaly']['dir'] %>
|
||||
cd <%= @options[:working_dir] %>
|
||||
|
||||
exec chpst -e <%= node['gitlab']['gitaly']['env_directory'] %> -P \
|
||||
-U <%= node['gitlab']['user']['username'] %> \
|
||||
-u <%= node['gitlab']['user']['username'] %> \
|
||||
<%= node['gitlab']['gitaly']['bin_path'] %>
|
||||
exec chpst -e <%= @options[:env_dir] %> -P \
|
||||
-U <%= @options[:user] %> \
|
||||
-u <%= @options[:user] %> \
|
||||
<%= @options[:bin_path] %> <%= @options[:config_path] %>
|
||||
|
|
|
@ -2,16 +2,14 @@ require 'chef_helper'
|
|||
|
||||
describe 'gitlab::gitaly' do
|
||||
let(:chef_run) { ChefSpec::SoloRunner.converge('gitlab::default') }
|
||||
config_path = '/var/opt/gitlab/gitaly/config.toml'
|
||||
let(:gitaly_config) { chef_run.template(config_path) }
|
||||
|
||||
before do
|
||||
allow(Gitlab).to receive(:[]).and_call_original
|
||||
end
|
||||
|
||||
context 'when gitaly is enabled' do
|
||||
before do
|
||||
stub_gitlab_rb(gitaly: { enable: true })
|
||||
end
|
||||
|
||||
context 'by default' do
|
||||
it_behaves_like "enabled runit service", "gitaly", "root", "root"
|
||||
|
||||
it 'creates expected directories with correct permissions' do
|
||||
|
@ -20,6 +18,36 @@ describe 'gitlab::gitaly' do
|
|||
expect(chef_run).to create_directory('/opt/gitlab/etc/gitaly')
|
||||
expect(chef_run).to create_file('/opt/gitlab/etc/gitaly/PATH')
|
||||
end
|
||||
|
||||
it 'populates gitaly config.toml with defaults' do
|
||||
expect(chef_run).to render_file(config_path)
|
||||
.with_content("socket_path = '/var/opt/gitlab/gitaly/gitaly.socket'")
|
||||
expect(chef_run).not_to render_file(config_path)
|
||||
.with_content("listen_addr = 'localhost:7777'")
|
||||
expect(chef_run).not_to render_file(config_path)
|
||||
.with_content("prometheus_listen_addr = 'localhost:9000'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'with user settings' do
|
||||
before do
|
||||
stub_gitlab_rb(
|
||||
gitaly: {
|
||||
socket_path: '/tmp/gitaly.socket',
|
||||
listen_addr: 'localhost:7777',
|
||||
prometheus_listen_addr: 'localhost:9000'
|
||||
}
|
||||
)
|
||||
end
|
||||
|
||||
it 'populates gitaly config.toml with custom values' do
|
||||
expect(chef_run).to render_file(config_path)
|
||||
.with_content("socket_path = '/tmp/gitaly.socket'")
|
||||
expect(chef_run).to render_file(config_path)
|
||||
.with_content("listen_addr = 'localhost:7777'")
|
||||
expect(chef_run).to render_file(config_path)
|
||||
.with_content("prometheus_listen_addr = 'localhost:9000'")
|
||||
end
|
||||
end
|
||||
|
||||
context 'when gitaly is disabled' do
|
||||
|
@ -33,6 +61,7 @@ describe 'gitlab::gitaly' do
|
|||
expect(chef_run).not_to create_directory('/var/opt/gitlab/gitaly')
|
||||
expect(chef_run).not_to create_directory('/var/log/gitlab/gitaly')
|
||||
expect(chef_run).not_to create_directory('/opt/gitlab/etc/gitaly')
|
||||
expect(chef_run).not_to create_file('/var/opt/gitlab/gitaly/config.toml')
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -208,7 +208,7 @@ describe 'gitlab::gitlab-rails' do
|
|||
|
||||
context 'when socket path is changed' do
|
||||
it 'sets the path to socket' do
|
||||
stub_gitlab_rb(gitaly: { env: { 'GITALY_SOCKET_PATH' => '/tmp/socket' } })
|
||||
stub_gitlab_rb(gitaly: { socket_path: '/tmp/socket' })
|
||||
expect(chef_run).to render_file(gitlab_yml_path)
|
||||
.with_content(%r{gitaly:\s+socket_path:\s+/tmp/socket})
|
||||
end
|
||||
|
|
|
@ -7,7 +7,6 @@ describe Gitaly do
|
|||
describe 'by default' do
|
||||
it 'provides settings needed for gitaly to run' do
|
||||
expect(chef_run.node['gitlab']['gitaly']['env']).to include(
|
||||
'GITALY_SOCKET_PATH' => '/var/opt/gitlab/gitaly/gitaly.socket',
|
||||
'HOME' => '/var/opt/gitlab',
|
||||
'PATH' => '/opt/gitlab/bin:/opt/gitlab/embedded/bin:/bin:/usr/bin'
|
||||
)
|
||||
|
@ -19,10 +18,10 @@ describe Gitaly do
|
|||
end
|
||||
|
||||
describe 'when unknown gitaly setting and new env is provided' do
|
||||
before { stub_gitlab_rb(gitaly: { socket_path: '/tmp/socket', env: { 'TEST' => 'true' } }) }
|
||||
before { stub_gitlab_rb(gitaly: { cool_feature: true, env: { 'TEST' => 'true' } }) }
|
||||
|
||||
it 'puts the setting into the environment and maintains other environment settings' do
|
||||
expect(chef_run.node['gitlab']['gitaly']['env']).to include('GITALY_SOCKET_PATH' => '/tmp/socket', 'TEST' => 'true')
|
||||
expect(chef_run.node['gitlab']['gitaly']['env']).to include('GITALY_COOL_FEATURE' => 'true', 'TEST' => 'true')
|
||||
end
|
||||
|
||||
it 'does not include known settings in the environment' do
|
||||
|
@ -31,10 +30,10 @@ describe Gitaly do
|
|||
end
|
||||
|
||||
describe 'when unkown gitaly setting is provided' do
|
||||
before { stub_gitlab_rb(gitaly: { socket_path: '/tmp/socket' }) }
|
||||
before { stub_gitlab_rb(gitaly: { cool_feature: true }) }
|
||||
|
||||
it 'puts the setting into the environment and maintians other environment settings' do
|
||||
expect(chef_run.node['gitlab']['gitaly']['env']).to include({ 'GITALY_SOCKET_PATH' => '/tmp/socket' })
|
||||
expect(chef_run.node['gitlab']['gitaly']['env']).to include({ 'GITALY_COOL_FEATURE' => 'true' })
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue