Commit 1295eba7 authored by Stan Hu's avatar Stan Hu

Merge branch 'revert-728bdaab' into 'master'

Revert "Merge branch 'remove-depend_on_persistent_pipeline_ref-feature-flag' into 'master'"

See merge request gitlab-org/gitlab!20423
parents ce328f94 a5af171e
...@@ -14,13 +14,15 @@ module Ci ...@@ -14,13 +14,15 @@ module Ci
delegate :ref_exists?, :create_ref, :delete_refs, to: :repository delegate :ref_exists?, :create_ref, :delete_refs, to: :repository
def exist? def exist?
return unless enabled?
ref_exists?(path) ref_exists?(path)
rescue rescue
false false
end end
def create def create
return if exist? return unless enabled? && !exist?
create_ref(sha, path) create_ref(sha, path)
rescue => e rescue => e
...@@ -29,6 +31,8 @@ module Ci ...@@ -29,6 +31,8 @@ module Ci
end end
def delete def delete
return unless enabled?
delete_refs(path) delete_refs(path)
rescue Gitlab::Git::Repository::NoRepository rescue Gitlab::Git::Repository::NoRepository
# no-op # no-op
...@@ -40,5 +44,11 @@ module Ci ...@@ -40,5 +44,11 @@ module Ci
def path def path
"refs/#{Repository::REF_PIPELINES}/#{pipeline.id}" "refs/#{Repository::REF_PIPELINES}/#{pipeline.id}"
end end
private
def enabled?
Feature.enabled?(:depend_on_persistent_pipeline_ref, project, default_enabled: true)
end
end end
end end
...@@ -468,3 +468,15 @@ To illustrate its life cycle: ...@@ -468,3 +468,15 @@ To illustrate its life cycle:
even if the commit history of the `example` branch has been overwritten by force-push. even if the commit history of the `example` branch has been overwritten by force-push.
1. GitLab Runner fetches the persistent pipeline ref and gets source code from the checkout-SHA. 1. GitLab Runner fetches the persistent pipeline ref and gets source code from the checkout-SHA.
1. When the pipeline finished, its persistent ref is cleaned up in a background process. 1. When the pipeline finished, its persistent ref is cleaned up in a background process.
NOTE: **NOTE**: At this moment, this feature is on by default and can be manually disabled
by disabling `depend_on_persistent_pipeline_ref` feature flag. If you're interested in
manually disabling this behavior, please ask the administrator
to execute the following commands in rails console.
```shell
> sudo gitlab-rails console # Login to Rails console of GitLab instance.
> project = Project.find_by_full_path('namespace/project-name') # Get the project instance.
> Feature.disable(:depend_on_persistent_pipeline_ref, project) # Disable the feature flag for specific project
> Feature.disable(:depend_on_persistent_pipeline_ref) # Disable the feature flag system-wide
```
...@@ -45,6 +45,18 @@ describe Ci::PersistentRef do ...@@ -45,6 +45,18 @@ describe Ci::PersistentRef do
expect(pipeline.persistent_ref).to be_exist expect(pipeline.persistent_ref).to be_exist
end end
context 'when depend_on_persistent_pipeline_ref feature flag is disabled' do
before do
stub_feature_flags(depend_on_persistent_pipeline_ref: false)
end
it 'does not create a persistent ref' do
expect(project.repository).not_to receive(:create_ref)
subject
end
end
context 'when sha does not exist in the repository' do context 'when sha does not exist in the repository' do
let(:sha) { 'not-exist' } let(:sha) { 'not-exist' }
......
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