Commit 15ddfa2b authored by Alejandro Rodríguez's avatar Alejandro Rodríguez

Pass timeout to RepositoryService.FetchRemote Gitaly RPC calls

parent 3d162d19
...@@ -43,8 +43,11 @@ module Gitlab ...@@ -43,8 +43,11 @@ module Gitlab
GitalyClient.call(@storage, :repository_service, :apply_gitattributes, request) GitalyClient.call(@storage, :repository_service, :apply_gitattributes, request)
end end
def fetch_remote(remote, ssh_auth: nil, forced: false, no_tags: false) def fetch_remote(remote, ssh_auth:, forced:, no_tags:, timeout:)
request = Gitaly::FetchRemoteRequest.new(repository: @gitaly_repo, remote: remote, force: forced, no_tags: no_tags) request = Gitaly::FetchRemoteRequest.new(
repository: @gitaly_repo, remote: remote, force: forced,
no_tags: no_tags, timeout: timeout
)
if ssh_auth&.ssh_import? if ssh_auth&.ssh_import?
if ssh_auth.ssh_key_auth? && ssh_auth.ssh_private_key.present? if ssh_auth.ssh_key_auth? && ssh_auth.ssh_private_key.present?
......
...@@ -128,7 +128,7 @@ module Gitlab ...@@ -128,7 +128,7 @@ module Gitlab
def fetch_remote(repository, remote, ssh_auth: nil, forced: false, no_tags: false) def fetch_remote(repository, remote, ssh_auth: nil, forced: false, no_tags: false)
gitaly_migrate(:fetch_remote) do |is_enabled| gitaly_migrate(:fetch_remote) do |is_enabled|
if is_enabled if is_enabled
repository.gitaly_repository_client.fetch_remote(remote, ssh_auth: ssh_auth, forced: forced, no_tags: no_tags) repository.gitaly_repository_client.fetch_remote(remote, ssh_auth: ssh_auth, forced: forced, no_tags: no_tags, timeout: git_timeout)
else else
storage_path = Gitlab.config.repositories.storages[repository.storage]["path"] storage_path = Gitlab.config.repositories.storages[repository.storage]["path"]
local_fetch_remote(storage_path, repository.relative_path, remote, ssh_auth: ssh_auth, forced: forced, no_tags: no_tags) local_fetch_remote(storage_path, repository.relative_path, remote, ssh_auth: ssh_auth, forced: forced, no_tags: no_tags)
......
...@@ -4,6 +4,7 @@ require 'stringio' ...@@ -4,6 +4,7 @@ require 'stringio'
describe Gitlab::Shell do describe Gitlab::Shell do
set(:project) { create(:project, :repository) } set(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:gitlab_shell) { described_class.new } let(:gitlab_shell) { described_class.new }
let(:popen_vars) { { 'GIT_TERMINAL_PROMPT' => ENV['GIT_TERMINAL_PROMPT'] } } let(:popen_vars) { { 'GIT_TERMINAL_PROMPT' => ENV['GIT_TERMINAL_PROMPT'] } }
let(:gitlab_projects) { double('gitlab_projects') } let(:gitlab_projects) { double('gitlab_projects') }
...@@ -201,8 +202,6 @@ describe Gitlab::Shell do ...@@ -201,8 +202,6 @@ describe Gitlab::Shell do
end end
shared_examples 'fetch_remote' do |gitaly_on| shared_examples 'fetch_remote' do |gitaly_on|
let(:repository) { project.repository }
def fetch_remote(ssh_auth = nil) def fetch_remote(ssh_auth = nil)
gitlab_shell.fetch_remote(repository.raw_repository, 'remote-name', ssh_auth: ssh_auth) gitlab_shell.fetch_remote(repository.raw_repository, 'remote-name', ssh_auth: ssh_auth)
end end
...@@ -325,6 +324,23 @@ describe Gitlab::Shell do ...@@ -325,6 +324,23 @@ describe Gitlab::Shell do
describe '#fetch_remote gitaly' do describe '#fetch_remote gitaly' do
it_should_behave_like 'fetch_remote', true it_should_behave_like 'fetch_remote', true
context 'gitaly call' do
let(:remote_name) { 'remote-name' }
let(:ssh_auth) { double(:ssh_auth) }
subject do
gitlab_shell.fetch_remote(repository.raw_repository, remote_name,
forced: true, no_tags: true, ssh_auth: ssh_auth)
end
it 'passes the correct params to the gitaly service' do
expect(repository.gitaly_repository_client).to receive(:fetch_remote)
.with(remote_name, ssh_auth: ssh_auth, forced: true, no_tags: true, timeout: timeout)
subject
end
end
end end
describe '#import_repository' do describe '#import_repository' do
......
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