Remove :find_remote_root_refs_inmemory feature flag

Changelog: other
parent 10139b88
---
name: find_remote_root_refs_inmemory
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/60583
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/329664
milestone: '13.12'
type: development
group: group::gitaly
default_enabled: true
......@@ -50,17 +50,11 @@ module Geo
end
def update_root_ref
if Feature.enabled?(:find_remote_root_refs_inmemory, default_enabled: :yaml)
authorization = ::Gitlab::Geo::RepoSyncRequest.new(
scope: repository.full_path
).authorization
authorization = ::Gitlab::Geo::RepoSyncRequest.new(
scope: repository.full_path
).authorization
project.update_root_ref(GEO_REMOTE_NAME, remote_url, authorization)
else
repository.with_config(jwt_authentication_header) do
project.update_root_ref(GEO_REMOTE_NAME, remote_url, nil)
end
end
project.update_root_ref(GEO_REMOTE_NAME, remote_url, authorization)
end
def execute_housekeeping
......
......@@ -233,93 +233,29 @@ RSpec.describe Geo::RepositorySyncService, :geo do
context 'with non empty repositories' do
let(:project) { create(:project, :repository) }
context 'with inmemory feature disabled' do
context 'when HEAD change' do
before do
stub_feature_flags(find_remote_root_refs_inmemory: false)
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything)
.and_return('feature')
end
context 'when HEAD change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, nil)
.and_return('feature')
end
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch with JWT credentials' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.twice
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
expect(project).to receive(:change_head).with('feature').once
subject.execute
end
subject.execute
end
context 'when HEAD does not change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, nil)
.and_return(project.default_branch)
end
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.once
it 'updates the default branch with JWT credentials' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.twice
expect(project).to receive(:change_head).with('feature').once
expect(project).to receive(:change_head).with('master').once
subject.execute
end
end
end
context 'with inmemory feature enabled' do
before do
stub_feature_flags(find_remote_root_refs_inmemory: true)
end
context 'when HEAD change' do
before do
allow(project.repository)
.to receive(:find_remote_root_ref)
.with('geo', url_to_repo, anything)
.and_return('feature')
end
it 'syncs gitattributes to info/attributes' do
expect(repository).to receive(:copy_gitattributes)
subject.execute
end
it 'updates the default branch' do
expect(repository).to receive(:with_config)
.with("http.#{url_to_repo}.extraHeader" => anything)
.and_call_original
.once
expect(project).to receive(:change_head).with('feature').once
subject.execute
end
subject.execute
end
context 'when HEAD does not change' do
......
......@@ -45,18 +45,9 @@ module Gitlab
# The remote_name parameter is deprecated and will be removed soon.
def find_remote_root_ref(remote_name, remote_url, authorization)
request = if Feature.enabled?(:find_remote_root_refs_inmemory, default_enabled: :yaml)
Gitaly::FindRemoteRootRefRequest.new(
repository: @gitaly_repo,
remote_url: remote_url,
http_authorization_header: authorization
)
else
Gitaly::FindRemoteRootRefRequest.new(
repository: @gitaly_repo,
remote: remote_name
)
end
request = Gitaly::FindRemoteRootRefRequest.new(repository: @gitaly_repo,
remote_url: remote_url,
http_authorization_header: authorization)
response = GitalyClient.call(@storage, :remote_service,
:find_remote_root_ref, request, timeout: GitalyClient.medium_timeout)
......
......@@ -38,47 +38,26 @@ RSpec.describe Gitlab::GitalyClient::RemoteService do
let(:remote) { 'origin' }
let(:url) { 'http://git.example.com/my-repo.git' }
let(:auth) { 'Basic secret' }
let(:expected_params) { { remote_url: url, http_authorization_header: auth } }
shared_examples 'a find_remote_root_ref call' do
it 'sends an find_remote_root_ref message and returns the root ref' do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return(double(ref: 'master'))
expect(client.find_remote_root_ref(remote, url, auth)).to eq 'master'
end
it 'ensure ref is a valid UTF-8 string' do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return(double(ref: "an_invalid_ref_\xE5"))
expect(client.find_remote_root_ref(remote, url, auth)).to eq "an_invalid_ref_å"
end
end
context 'with inmemory feature enabled' do
before do
stub_feature_flags(find_remote_root_refs_inmemory: true)
end
it 'sends an find_remote_root_ref message and returns the root ref' do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return(double(ref: 'master'))
it_behaves_like 'a find_remote_root_ref call' do
let(:expected_params) { { remote_url: url, http_authorization_header: auth } }
end
expect(client.find_remote_root_ref(remote, url, auth)).to eq 'master'
end
context 'with inmemory feature disabled' do
before do
stub_feature_flags(find_remote_root_refs_inmemory: false)
end
it 'ensure ref is a valid UTF-8 string' do
expect_any_instance_of(Gitaly::RemoteService::Stub)
.to receive(:find_remote_root_ref)
.with(gitaly_request_with_path(storage_name, relative_path), kind_of(Hash))
.with(gitaly_request_with_params(expected_params), kind_of(Hash))
.and_return(double(ref: "an_invalid_ref_\xE5"))
it_behaves_like 'a find_remote_root_ref call' do
let(:expected_params) { { remote: remote } }
end
expect(client.find_remote_root_ref(remote, url, auth)).to eq "an_invalid_ref_å"
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