Commit 0a1c8bb3 authored by Ahmad Sherif's avatar Ahmad Sherif

Pass Gitaly resource path to gitlab-workhorse if Gitaly is enabled

parent 4b43126d
---
title: Pass Gitaly resource path to gitlab-workhorse if Gitaly is enabled
merge_request: 8440
author:
...@@ -403,6 +403,12 @@ Settings.rack_attack.git_basic_auth['maxretry'] ||= 10 ...@@ -403,6 +403,12 @@ Settings.rack_attack.git_basic_auth['maxretry'] ||= 10
Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute Settings.rack_attack.git_basic_auth['findtime'] ||= 1.minute
Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour Settings.rack_attack.git_basic_auth['bantime'] ||= 1.hour
#
# Gitaly
#
Settings['gitaly'] ||= Settingslogic.new({})
Settings.gitaly['socket_path'] ||= ENV['GITALY_SOCKET_PATH']
# #
# Testing settings # Testing settings
# #
......
...@@ -15,10 +15,17 @@ module Gitlab ...@@ -15,10 +15,17 @@ module Gitlab
class << self class << self
def git_http_ok(repository, user) def git_http_ok(repository, user)
{ params = {
GL_ID: Gitlab::GlId.gl_id(user), GL_ID: Gitlab::GlId.gl_id(user),
RepoPath: repository.path_to_repo, 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 end
def lfs_upload_ok(oid, size) def lfs_upload_ok(oid, size)
......
...@@ -174,4 +174,27 @@ describe Gitlab::Workhorse, lib: true do ...@@ -174,4 +174,27 @@ describe Gitlab::Workhorse, lib: true do
described_class.verify_api_request!(headers) described_class.verify_api_request!(headers)
end end
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 end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment