Commit 09751c75 authored by Ahmad Sherif's avatar Ahmad Sherif

Add support for Gitaly calls over TCP connection

Closes gitaly#166
parent 2fceb437
...@@ -461,7 +461,7 @@ production: &base ...@@ -461,7 +461,7 @@ production: &base
storages: # You must have at least a `default` storage path. storages: # You must have at least a `default` storage path.
default: default:
path: /home/git/repositories/ path: /home/git/repositories/
gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket gitaly_address: unix:/home/git/gitlab/tmp/sockets/private/gitaly.socket # TCP connections are supported too (e.g. tcp://host:port)
## Backup settings ## Backup settings
backup: backup:
......
...@@ -9,7 +9,7 @@ if Gitlab.config.gitaly.enabled || Rails.env.test? ...@@ -9,7 +9,7 @@ if Gitlab.config.gitaly.enabled || Rails.env.test?
raise "storage #{name.inspect} is missing a gitaly_address" raise "storage #{name.inspect} is missing a gitaly_address"
end end
unless URI(address).scheme == 'unix' unless URI(address).scheme.in?(%w(tcp unix))
raise "Unsupported Gitaly address: #{address.inspect}" raise "Unsupported Gitaly address: #{address.inspect}"
end end
......
...@@ -12,9 +12,11 @@ module Gitlab ...@@ -12,9 +12,11 @@ module Gitlab
end end
def self.new_channel(address) def self.new_channel(address)
# NOTE: Gitaly currently runs on a Unix socket, so permissions are address = address.sub(%r{^tcp://}, '') if URI(address).scheme == 'tcp'
# NOTE: When Gitaly runs on a Unix socket, permissions are
# handled using the file system and no additional authentication is # handled using the file system and no additional authentication is
# required (therefore the :this_channel_is_insecure flag) # required (therefore the :this_channel_is_insecure flag)
# TODO: Add authentication support when Gitaly is running on a TCP socket.
GRPC::Core::Channel.new(address, {}, :this_channel_is_insecure) GRPC::Core::Channel.new(address, {}, :this_channel_is_insecure)
end end
......
require 'spec_helper'
describe Gitlab::GitalyClient, lib: true do
describe '.new_channel' do
context 'when passed a UNIX socket address' do
it 'passes the address as-is to GRPC::Core::Channel initializer' do
address = 'unix:/tmp/gitaly.sock'
expect(GRPC::Core::Channel).to receive(:new).with(address, any_args)
described_class.new_channel(address)
end
end
context 'when passed a TCP address' do
it 'strips tcp:// prefix before passing it to GRPC::Core::Channel initializer' do
address = 'localhost:9876'
prefixed_address = "tcp://#{address}"
expect(GRPC::Core::Channel).to receive(:new).with(address, any_args)
described_class.new_channel(prefixed_address)
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