summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAhmad Sherif <me@ahmadsherif.com>2016-12-26 19:15:40 +0200
committerAhmad Sherif <me@ahmadsherif.com>2017-01-18 19:43:17 +0200
commit0a1c8bb37cbfe550e7c29b8f30c607cf985466df (patch)
tree7686e1296ed4935bb8fc79e809411fd44aaa6bc9
parent4b43126d08972c201551fbd1fe42e85847d5e03f (diff)
downloadgitlab-ce-feature/gitaly-feature-flag.tar.gz
Pass Gitaly resource path to gitlab-workhorse if Gitaly is enabledfeature/gitaly-feature-flag
-rw-r--r--changelogs/unreleased/feature-gitaly-feature-flag.yml4
-rw-r--r--config/initializers/1_settings.rb6
-rw-r--r--lib/gitlab/workhorse.rb9
-rw-r--r--spec/lib/gitlab/workhorse_spec.rb23
4 files changed, 41 insertions, 1 deletions
diff --git a/changelogs/unreleased/feature-gitaly-feature-flag.yml b/changelogs/unreleased/feature-gitaly-feature-flag.yml
new file mode 100644
index 00000000000..1fa566aeb10
--- /dev/null
+++ b/changelogs/unreleased/feature-gitaly-feature-flag.yml
@@ -0,0 +1,4 @@
+---
+title: Pass Gitaly resource path to gitlab-workhorse if Gitaly is enabled
+merge_request: 8440
+author:
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index ee97b4e42b9..906ec11f012 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -404,6 +404,12 @@ Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute
Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
#
+# Gitaly
+#
+Settings['gitaly'] ||= Settingslogic.new({})
+Settings.gitaly['socket_path'] ||= ENV['GITALY_SOCKET_PATH']
+
+#
# Testing settings
#
if Rails.env.test?
diff --git a/lib/gitlab/workhorse.rb b/lib/gitlab/workhorse.rb
index d28bb583fe7..a3b502ffd6a 100644
--- a/lib/gitlab/workhorse.rb
+++ b/lib/gitlab/workhorse.rb
@@ -15,10 +15,17 @@ module Gitlab
class << self
def git_http_ok(repository, user)
- {
+ params = {
GL_ID: Gitlab::GlId.gl_id(user),
RepoPath: repository.path_to_repo,
}
+
+ params.merge!(
+ GitalySocketPath: Gitlab.config.gitaly.socket_path,
+ GitalyResourcePath: "/projects/#{repository.project.id}/git-http/info-refs",
+ ) if Gitlab.config.gitaly.socket_path.present?
+
+ params
end
def lfs_upload_ok(oid, size)
diff --git a/spec/lib/gitlab/workhorse_spec.rb b/spec/lib/gitlab/workhorse_spec.rb
index 61da91dcbd3..4b1cd466677 100644
--- a/spec/lib/gitlab/workhorse_spec.rb
+++ b/spec/lib/gitlab/workhorse_spec.rb
@@ -174,4 +174,27 @@ describe Gitlab::Workhorse, lib: true do
described_class.verify_api_request!(headers)
end
end
+
+ describe '.git_http_ok' do
+ let(:user) { create(:user) }
+
+ subject { described_class.git_http_ok(repository, user) }
+
+ it { expect(subject).to eq({ GL_ID: "user-#{user.id}", RepoPath: repository.path_to_repo }) }
+
+ context 'when Gitaly socket path is present' do
+ let(:gitaly_socket_path) { '/tmp/gitaly.sock' }
+
+ before do
+ allow(Gitlab.config.gitaly).to receive(:socket_path).and_return(gitaly_socket_path)
+ end
+
+ it 'includes Gitaly params in the returned value' do
+ expect(subject).to include({
+ GitalyResourcePath: "/projects/#{repository.project.id}/git-http/info-refs",
+ GitalySocketPath: gitaly_socket_path,
+ })
+ end
+ end
+ end
end