diff options
author | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-10-03 15:54:44 +0300 |
---|---|---|
committer | Zeger-Jan van de Weg <git@zjvandeweg.nl> | 2019-10-03 15:54:44 +0300 |
commit | 6b748466dc0c885d100436d35636b730005d4d10 (patch) | |
tree | 9047c38c7abee8e6a1998dd2fffe0695ab8c7464 | |
parent | b3294d44835329f7759f15c7a25834e6ca7260ca (diff) | |
parent | e206541cfbe72b841f720deafa68afc539d1964c (diff) |
Merge branch 'sh-add-git-search-path' into 'master'
Support configurable Git config search path for Rugged
Closes #2051
See merge request gitlab-org/gitaly!1526
-rw-r--r-- | changelogs/unreleased/sh-add-git-search-path.yml | 5 | ||||
-rw-r--r-- | config.toml.example | 4 | ||||
-rw-r--r-- | internal/config/ruby.go | 8 | ||||
-rw-r--r-- | internal/rubyserver/rubyserver.go | 3 | ||||
-rwxr-xr-x | ruby/bin/gitaly-ruby | 10 | ||||
-rw-r--r-- | ruby/lib/gitlab/config.rb | 4 |
6 files changed, 33 insertions, 1 deletions
diff --git a/changelogs/unreleased/sh-add-git-search-path.yml b/changelogs/unreleased/sh-add-git-search-path.yml new file mode 100644 index 000000000..18f0f64c9 --- /dev/null +++ b/changelogs/unreleased/sh-add-git-search-path.yml @@ -0,0 +1,5 @@ +--- +title: Support configurable Git config search path for Rugged +merge_request: 1526 +author: +type: fixed diff --git a/config.toml.example b/config.toml.example index 3ef031451..fccfc31d9 100644 --- a/config.toml.example +++ b/config.toml.example @@ -73,6 +73,10 @@ dir = "/home/git/gitaly/ruby" # # # Number of gitaly-ruby worker processes # num_workers = 2 +# +# # Search path for system gitconfig file (e.g. /etc, /opt/gitlab/embedded/etc) +# # NOTE: This only affects RPCs that use Rugged. +# rugged_git_config_search_path = "/etc" [gitlab-shell] # The directory where gitlab-shell is installed diff --git a/internal/config/ruby.go b/internal/config/ruby.go index c10cb4e84..6cf4e2e52 100644 --- a/internal/config/ruby.go +++ b/internal/config/ruby.go @@ -16,6 +16,7 @@ type Ruby struct { RestartDelayToml duration `toml:"restart_delay"` NumWorkers int `toml:"num_workers"` LinguistLanguagesPath string `toml:"linguist_languages_path"` + RuggedGitConfigSearchPath string `toml:"rugged_git_config_search_path"` } // This type is a trick to let our TOML library parse durations from strings. @@ -60,5 +61,12 @@ func ConfigureRuby() error { return err } + if len(Config.Ruby.RuggedGitConfigSearchPath) != 0 { + Config.Ruby.RuggedGitConfigSearchPath, err = filepath.Abs(Config.Ruby.RuggedGitConfigSearchPath) + if err != nil { + return err + } + } + return validateIsDirectory(Config.Ruby.Dir, "gitaly-ruby.dir") } diff --git a/internal/rubyserver/rubyserver.go b/internal/rubyserver/rubyserver.go index 82f806c5c..b9cc7d19d 100644 --- a/internal/rubyserver/rubyserver.go +++ b/internal/rubyserver/rubyserver.go @@ -119,7 +119,8 @@ func (s *Server) start() error { "GITALY_RUBY_GITALY_BIN_DIR="+cfg.BinDir, "GITALY_RUBY_DIR="+cfg.Ruby.Dir, "GITALY_VERSION="+version.GetVersion(), - "GITALY_GIT_HOOKS_DIR="+hooks.Path()) + "GITALY_GIT_HOOKS_DIR="+hooks.Path(), + "GITALY_RUGGED_GIT_CONFIG_SEARCH_PATH="+cfg.Ruby.RuggedGitConfigSearchPath) env = append(env, gitlabshell.Env()...) env = append(env, command.GitEnv...) diff --git a/ruby/bin/gitaly-ruby b/ruby/bin/gitaly-ruby index bfec5ee36..4e6087391 100755 --- a/ruby/bin/gitaly-ruby +++ b/ruby/bin/gitaly-ruby @@ -4,6 +4,7 @@ require 'fileutils' require 'grpc' require 'gitlab-labkit' +require 'rugged' require_relative '../lib/gitaly_server.rb' require_relative '../lib/gitaly_server/sentry_interceptor.rb' @@ -24,6 +25,7 @@ def main FileUtils.mkdir_p(socket_dir) File.chmod(0700, socket_dir) + set_rugged_search_path load_distributed_tracing load_tracing @@ -59,6 +61,14 @@ def main run_thread.join end +def set_rugged_search_path + search_path = Gitlab::Config::Git.new.rugged_git_config_search_path + + return unless search_path + + Rugged::Settings['search_path_system'] = search_path +end + def load_distributed_tracing return unless Labkit::Tracing.enabled? diff --git a/ruby/lib/gitlab/config.rb b/ruby/lib/gitlab/config.rb index 2763e55f2..d644d88aa 100644 --- a/ruby/lib/gitlab/config.rb +++ b/ruby/lib/gitlab/config.rb @@ -35,6 +35,10 @@ module Gitlab def max_commit_or_tag_message_size @max_commit_or_tag_message_size ||= ENV['GITALY_RUBY_MAX_COMMIT_OR_TAG_MESSAGE_SIZE'].to_i end + + def rugged_git_config_search_path + @rugged_git_config_search_path ||= ENV['GITALY_RUGGED_GIT_CONFIG_SEARCH_PATH'] + end end class GitlabShell |