Commit bc5191ed authored by Stan Hu's avatar Stan Hu

Merge branch 'remove-redundant-persistent-ref-check' into 'master'

Skip Redundant Persistent Ref existence check

See merge request gitlab-org/gitlab!32391
parents 4a147c20 4fd05ce9
...@@ -97,6 +97,13 @@ module Ci ...@@ -97,6 +97,13 @@ module Ci
end end
def persistent_ref_exist? def persistent_ref_exist?
##
# Persistent refs for pipelines definitely exist from GitLab 12.4,
# hence, we don't need to check the ref existence before passing it to runners.
# Checking refs pressurizes gitaly node and should be avoided.
# Issue: https://gitlab.com/gitlab-com/gl-infra/production/-/issues/2143
return true if Feature.enabled?(:ci_skip_persistent_ref_existence_check)
pipeline.persistent_ref.exist? pipeline.persistent_ref.exist?
end end
......
...@@ -185,16 +185,19 @@ describe Ci::BuildRunnerPresenter do ...@@ -185,16 +185,19 @@ describe Ci::BuildRunnerPresenter do
subject { presenter.refspecs } subject { presenter.refspecs }
let(:build) { create(:ci_build) } let(:build) { create(:ci_build) }
let(:pipeline) { build.pipeline }
it 'returns the correct refspecs' do it 'returns the correct refspecs' do
is_expected.to contain_exactly("+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}") is_expected.to contain_exactly("+refs/heads/#{build.ref}:refs/remotes/origin/#{build.ref}",
"+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}")
end end
context 'when ref is tag' do context 'when ref is tag' do
let(:build) { create(:ci_build, :tag) } let(:build) { create(:ci_build, :tag) }
it 'returns the correct refspecs' do it 'returns the correct refspecs' do
is_expected.to contain_exactly("+refs/tags/#{build.ref}:refs/tags/#{build.ref}") is_expected.to contain_exactly("+refs/tags/#{build.ref}:refs/tags/#{build.ref}",
"+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}")
end end
context 'when GIT_DEPTH is zero' do context 'when GIT_DEPTH is zero' do
...@@ -204,7 +207,8 @@ describe Ci::BuildRunnerPresenter do ...@@ -204,7 +207,8 @@ describe Ci::BuildRunnerPresenter do
it 'returns the correct refspecs' do it 'returns the correct refspecs' do
is_expected.to contain_exactly('+refs/tags/*:refs/tags/*', is_expected.to contain_exactly('+refs/tags/*:refs/tags/*',
'+refs/heads/*:refs/remotes/origin/*') '+refs/heads/*:refs/remotes/origin/*',
"+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}")
end end
end end
end end
......
...@@ -471,7 +471,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -471,7 +471,8 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
'sha' => job.sha, 'sha' => job.sha,
'before_sha' => job.before_sha, 'before_sha' => job.before_sha,
'ref_type' => 'branch', 'ref_type' => 'branch',
'refspecs' => ["+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}"], 'refspecs' => ["+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}",
"+refs/heads/#{job.ref}:refs/remotes/origin/#{job.ref}"],
'depth' => project.ci_default_git_depth } 'depth' => project.ci_default_git_depth }
end end
...@@ -578,7 +579,9 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -578,7 +579,9 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['refspecs']) expect(json_response['git_info']['refspecs'])
.to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*') .to contain_exactly("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}",
'+refs/tags/*:refs/tags/*',
'+refs/heads/*:refs/remotes/origin/*')
end end
end end
end end
...@@ -638,7 +641,9 @@ describe API::Runner, :clean_gitlab_redis_shared_state do ...@@ -638,7 +641,9 @@ describe API::Runner, :clean_gitlab_redis_shared_state do
expect(response).to have_gitlab_http_status(:created) expect(response).to have_gitlab_http_status(:created)
expect(json_response['git_info']['refspecs']) expect(json_response['git_info']['refspecs'])
.to contain_exactly('+refs/tags/*:refs/tags/*', '+refs/heads/*:refs/remotes/origin/*') .to contain_exactly("+refs/pipelines/#{pipeline.id}:refs/pipelines/#{pipeline.id}",
'+refs/tags/*:refs/tags/*',
'+refs/heads/*:refs/remotes/origin/*')
end 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