diff --git a/app/services/ci/pipelines/clear_persistent_ref_service.rb b/app/services/ci/pipelines/clear_persistent_ref_service.rb index a3980d5905590cf26ce25180b2205abe72bebbfc..c2e4928e59154e2e35d6c11b4b515acafaf4e493 100644 --- a/app/services/ci/pipelines/clear_persistent_ref_service.rb +++ b/app/services/ci/pipelines/clear_persistent_ref_service.rb @@ -6,9 +6,7 @@ class ClearPersistentRefService < CreatePersistentRefService def execute Rails.cache.delete(pipeline_persistent_ref_cache_key) - if Feature.enabled?(:pipeline_delete_gitaly_refs_in_batches, pipeline.project) - pipeline.persistent_ref.async_delete - elsif Feature.enabled?(:pipeline_cleanup_ref_worker_async, pipeline.project) + if Feature.enabled?(:pipeline_cleanup_ref_worker_async, pipeline.project) ::Ci::PipelineCleanupRefWorker.perform_async(pipeline.id) else pipeline.persistent_ref.delete diff --git a/config/feature_flags/development/pipeline_delete_gitaly_refs_in_batches.yml b/config/feature_flags/development/pipeline_delete_gitaly_refs_in_batches.yml deleted file mode 100644 index 66e23fa424a3393e93f664a898f804ee6c79c62e..0000000000000000000000000000000000000000 --- a/config/feature_flags/development/pipeline_delete_gitaly_refs_in_batches.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -name: pipeline_delete_gitaly_refs_in_batches -introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/125333 -rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/416969 -milestone: '16.3' -type: development -group: group::gitaly -default_enabled: false diff --git a/doc/user/project/repository/monorepos/troubleshooting.md b/doc/user/project/repository/monorepos/troubleshooting.md index 769a6094caa44ffa916d756957993bf7d0edb736..763d6ac492dccf139844a50178364a097fea3f88 100644 --- a/doc/user/project/repository/monorepos/troubleshooting.md +++ b/doc/user/project/repository/monorepos/troubleshooting.md @@ -90,8 +90,9 @@ These feature flags do not need downtime to enable. - `merge_request_cleanup_ref_worker_async` - `pipeline_cleanup_ref_worker_async` -- `pipeline_delete_gitaly_refs_in_batches` - `merge_request_delete_gitaly_refs_in_batches` +> - [Generally available](https://gitlab.com/gitlab-org/gitlab/-/issues/416969) in GitLab 18.5. Feature flag `pipeline_delete_gitaly_refs_in_batches` removed. + [Epic 4220](https://gitlab.com/groups/gitlab-org/-/epics/4220) proposes to add RefTable support in GitLab, which is considered a long-term solution. diff --git a/spec/models/ci/persistent_ref_spec.rb b/spec/models/ci/persistent_ref_spec.rb index 9b3f9a8e094b99716fba0f937fdac4b9abd1cabc..edfc76376c0331ccb8b4d433eb528beb8298ee4d 100644 --- a/spec/models/ci/persistent_ref_spec.rb +++ b/spec/models/ci/persistent_ref_spec.rb @@ -11,32 +11,26 @@ .by(1) end - context 'when pipeline_delete_gitaly_refs_in_batches is disabled' do + it 'cleans up persistent refs after pipeline finished' do + pipeline = create(:ci_pipeline, :running) + + expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async).with(pipeline.id) + + pipeline.succeed! + end + + context 'when pipeline_cleanup_ref_worker_async is disabled' do before do - stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false) + stub_feature_flags(pipeline_cleanup_ref_worker_async: false) end it 'cleans up persistent refs after pipeline finished' do pipeline = create(:ci_pipeline, :running) - expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async).with(pipeline.id) + expect(pipeline.persistent_ref).to receive(:delete).once pipeline.succeed! end - - context 'when pipeline_cleanup_ref_worker_async is disabled' do - before do - stub_feature_flags(pipeline_cleanup_ref_worker_async: false) - end - - it 'cleans up persistent refs after pipeline finished' do - pipeline = create(:ci_pipeline, :running) - - expect(pipeline.persistent_ref).to receive(:delete).once - - pipeline.succeed! - end - end end describe '#exist?' do diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index 61d7ec4bad0f545509e37ef8ef10f28f6388f08b..6b0015c6b049924245c813ea882c9dc0023fd48a 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -1903,40 +1903,19 @@ def create_build(name, status) pipeline.public_send(action) end - context 'when pipeline_delete_gitaly_refs_in_batches is disabled' do + context 'when pipeline_cleanup_ref_worker_async is disabled' do before do - stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false) + stub_feature_flags(pipeline_cleanup_ref_worker_async: false) end - it 'deletes a persistent ref asynchronously via ::Ci::PipelineCleanupRefWorker', :sidekiq_inline do - expect(pipeline.persistent_ref).not_to receive(:delete_refs) + it 'deletes a persistent ref synchronously' do + expect(Ci::PipelineCleanupRefWorker).not_to receive(:perform_async).with(pipeline.id) - expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async) - .with(pipeline.id).and_call_original - - expect_next_instance_of(Ci::PersistentRef) do |persistent_ref| - expect(persistent_ref).to receive(:delete_refs) - .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}").once - end + expect(pipeline.persistent_ref).to receive(:delete_refs).once + .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}") pipeline.public_send(action) end - - context 'when pipeline_cleanup_ref_worker_async is disabled' do - before do - stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false) - stub_feature_flags(pipeline_cleanup_ref_worker_async: false) - end - - it 'deletes a persistent ref synchronously' do - expect(Ci::PipelineCleanupRefWorker).not_to receive(:perform_async).with(pipeline.id) - - expect(pipeline.persistent_ref).to receive(:delete_refs).once - .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}") - - pipeline.public_send(action) - end - end end end end diff --git a/spec/services/ci/pipelines/clear_persistent_ref_service_spec.rb b/spec/services/ci/pipelines/clear_persistent_ref_service_spec.rb index 8216e39f9eff234b62abdade31668eb56447aa7a..7411c178c838add6565f132b3cc5e88cbd26e524 100644 --- a/spec/services/ci/pipelines/clear_persistent_ref_service_spec.rb +++ b/spec/services/ci/pipelines/clear_persistent_ref_service_spec.rb @@ -20,41 +20,34 @@ .to change { Rails.cache.read(service.send(:pipeline_persistent_ref_cache_key)) }.from(true).to(nil) end - context 'when pipeline_delete_gitaly_refs_in_batches is disabled' do - before do - stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false) - end + it 'deletes a persistent ref asynchronously via ::Ci::PipelineCleanupRefWorker', :sidekiq_inline do + expect(pipeline.persistent_ref).not_to receive(:delete_refs) - it 'deletes a persistent ref asynchronously via ::Ci::PipelineCleanupRefWorker', :sidekiq_inline do - expect(pipeline.persistent_ref).not_to receive(:delete_refs) + expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async) + .with(pipeline.id).and_call_original - expect(Ci::PipelineCleanupRefWorker).to receive(:perform_async) - .with(pipeline.id).and_call_original + expect_next_instance_of(Ci::PersistentRef) do |persistent_ref| + expect(persistent_ref).to receive(:delete_refs) + .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}").once + end - expect_next_instance_of(Ci::PersistentRef) do |persistent_ref| - expect(persistent_ref).to receive(:delete_refs) - .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}").once - end + expect { service.execute } + .to change { Rails.cache.read(service.send(:pipeline_persistent_ref_cache_key)) }.from(true).to(nil) + end - expect { service.execute } - .to change { Rails.cache.read(service.send(:pipeline_persistent_ref_cache_key)) }.from(true).to(nil) + context 'when pipeline_cleanup_ref_worker_async is disabled' do + before do + stub_feature_flags(pipeline_cleanup_ref_worker_async: false) end - context 'when pipeline_cleanup_ref_worker_async is disabled' do - before do - stub_feature_flags(pipeline_delete_gitaly_refs_in_batches: false) - stub_feature_flags(pipeline_cleanup_ref_worker_async: false) - end + it 'deletes a persistent ref synchronously' do + expect(Ci::PipelineCleanupRefWorker).not_to receive(:perform_async).with(pipeline.id) - it 'deletes a persistent ref synchronously' do - expect(Ci::PipelineCleanupRefWorker).not_to receive(:perform_async).with(pipeline.id) + expect(pipeline.persistent_ref).to receive(:delete_refs).once + .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}") - expect(pipeline.persistent_ref).to receive(:delete_refs).once - .with("refs/#{Repository::REF_PIPELINES}/#{pipeline.id}") - - expect { service.execute } - .to change { Rails.cache.read(service.send(:pipeline_persistent_ref_cache_key)) }.from(true).to(nil) - end + expect { service.execute } + .to change { Rails.cache.read(service.send(:pipeline_persistent_ref_cache_key)) }.from(true).to(nil) end end end