Commit 3c8a1ef8 authored by Patrick Steinhardt's avatar Patrick Steinhardt

Convert setting the full path via SetFullPath RPC

When writing a repo's path (e.g. "gitlab-org/gitlab") into the
gitconfig, we currently use the `SetConfig()` RPC. This RPC has been
deprecated by Gitaly in favor of a new `SetFullPath()`, which can only
be used to explicitly write the repo's path into the gitconfig.

Convert the code to use the new RPC.
parent b0e2977c
818f3d85a2c8e6596376f1d2276aa22660203a6c
d513d220b183d83ae7219ec52f49aa3b4f7fc551
......@@ -472,7 +472,7 @@ end
gem 'spamcheck', '~> 0.1.0'
# Gitaly GRPC protocol definitions
gem 'gitaly', '~> 14.1.0.pre.rc4'
gem 'gitaly', '~> 14.2.0.pre.rc2'
# KAS GRPC protocol definitions
gem 'kas-grpc', '~> 0.0.2'
......
......@@ -452,7 +452,7 @@ GEM
rails (>= 3.2.0)
git (1.7.0)
rchardet (~> 1.8)
gitaly (14.1.0.pre.rc4)
gitaly (14.2.0.pre.rc2)
grpc (~> 1.0)
github-markup (1.7.0)
gitlab (4.16.1)
......@@ -1464,7 +1464,7 @@ DEPENDENCIES
gettext (~> 3.3)
gettext_i18n_rails (~> 1.8.0)
gettext_i18n_rails_js (~> 1.3)
gitaly (~> 14.1.0.pre.rc4)
gitaly (~> 14.2.0.pre.rc2)
github-markup (~> 1.7.0)
gitlab-chronic (~> 0.10.5)
gitlab-dangerfiles (~> 2.3.0)
......
---
name: set_full_path
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/66929
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/337002
milestone: '14.2'
type: development
group: group::gitaly
default_enabled: false
......@@ -911,8 +911,12 @@ module Gitlab
# This guard avoids Gitaly log/error spam
raise NoRepository, 'repository does not exist' unless exists?
if Feature.enabled?(:set_full_path)
gitaly_repository_client.set_full_path(full_path)
else
set_config('gitlab.fullpath' => full_path)
end
end
def set_config(entries)
wrapped_gitaly_errors do
......
......@@ -263,6 +263,21 @@ module Gitlab
GitalyClient.call(@storage, :repository_service, :write_ref, request, timeout: GitalyClient.fast_timeout)
end
def set_full_path(path)
GitalyClient.call(
@storage,
:repository_service,
:set_full_path,
Gitaly::SetFullPathRequest.new(
repository: @gitaly_repo,
path: path
),
timeout: GitalyClient.fast_timeout
)
nil
end
def set_config(entries)
return if entries.empty?
......
......@@ -1730,6 +1730,7 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
end
describe '#set_full_path' do
shared_examples '#set_full_path' do
before do
repository_rugged.config["gitlab.fullpath"] = repository_path
end
......@@ -1769,6 +1770,23 @@ RSpec.describe Gitlab::Git::Repository, :seed_helper do
end
end
context 'with :set_full_path enabled' do
before do
stub_feature_flags(set_full_path: true)
end
it_behaves_like '#set_full_path'
end
context 'with :set_full_path disabled' do
before do
stub_feature_flags(set_full_path: false)
end
it_behaves_like '#set_full_path'
end
end
describe '#set_config' do
let(:repository) { mutable_repository }
let(:entries) do
......
......@@ -333,4 +333,17 @@ RSpec.describe Gitlab::GitalyClient::RepositoryService do
client.replicate(source_repository)
end
end
describe '#set_full_path' do
let(:path) { 'repo/path' }
it 'sends a set_full_path message' do
expect_any_instance_of(Gitaly::RepositoryService::Stub)
.to receive(:set_full_path)
.with(gitaly_request_with_params(path: path), kind_of(Hash))
.and_return(double)
client.set_full_path(path)
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