diff --git a/app/services/ci/job_artifacts/update_unknown_locked_status_service.rb b/app/services/ci/job_artifacts/update_unknown_locked_status_service.rb index 0d35a90ed04420ece62314b94aef69c211115691..80b4efc615ee578c2711a1280764a0f89a17a4ca 100644 --- a/app/services/ci/job_artifacts/update_unknown_locked_status_service.rb +++ b/app/services/ci/job_artifacts/update_unknown_locked_status_service.rb @@ -17,7 +17,11 @@ def initialize @removed_count = 0 @locked_count = 0 @start_at = Time.current - @loop_limit = Feature.enabled?(:ci_job_artifacts_backlog_large_loop_limit) ? LARGE_LOOP_LIMIT : LOOP_LIMIT + @loop_limit = if Feature.enabled?(:ci_job_artifacts_backlog_large_loop_limit, type: :ops) + LARGE_LOOP_LIMIT + else + LOOP_LIMIT + end end def execute @@ -35,9 +39,9 @@ def update_locked_status_on_unknown_artifacts unknown_status_build_ids = safely_ordered_ci_job_artifacts_locked_unknown_relation.pluck_job_id.uniq locked_pipe_build_ids = ::Ci::Build - .with_pipeline_locked_artifacts - .id_in(unknown_status_build_ids) - .pluck_primary_key + .with_pipeline_locked_artifacts + .id_in(unknown_status_build_ids) + .pluck_primary_key @locked_count += update_unknown_artifacts(locked_pipe_build_ids, Ci::JobArtifact.lockeds[:artifacts_locked]) diff --git a/config/feature_flags/development/ci_job_artifacts_backlog_large_loop_limit.yml b/config/feature_flags/ops/ci_job_artifacts_backlog_large_loop_limit.yml similarity index 93% rename from config/feature_flags/development/ci_job_artifacts_backlog_large_loop_limit.yml rename to config/feature_flags/ops/ci_job_artifacts_backlog_large_loop_limit.yml index 395580a4d802f91b633120178af6c54d8ef165a1..94645bc391d11a6171edde7e57b4aee37df392f1 100644 --- a/config/feature_flags/development/ci_job_artifacts_backlog_large_loop_limit.yml +++ b/config/feature_flags/ops/ci_job_artifacts_backlog_large_loop_limit.yml @@ -3,6 +3,6 @@ name: ci_job_artifacts_backlog_large_loop_limit introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/76509 rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/347151 milestone: '14.10' -type: development +type: ops group: group::pipeline security default_enabled: false diff --git a/spec/services/ci/job_artifacts/update_unknown_locked_status_service_spec.rb b/spec/services/ci/job_artifacts/update_unknown_locked_status_service_spec.rb index 5f6a89b89e16300b3d6b1925e4276290a7b7edfe..22ef218512e55e8ae43ebabd771f9fb9c119b1a9 100644 --- a/spec/services/ci/job_artifacts/update_unknown_locked_status_service_spec.rb +++ b/spec/services/ci/job_artifacts/update_unknown_locked_status_service_spec.rb @@ -87,19 +87,39 @@ end context 'due to @loop_limit' do - before do - stub_const("#{described_class}::LARGE_LOOP_LIMIT", 1) - end + context 'when feature flag ci_job_artifacts_backlog_large_loop_limit is enabled' do + before do + stub_const("#{described_class}::LARGE_LOOP_LIMIT", 1) + end - it 'affects the most recently expired artifact first' do - subject + it 'affects the most recently expired artifact first' do + subject - expect(unknown_locked_artifact.reload.locked).to eq('artifacts_locked') - expect(unknown_unlocked_artifact.reload.locked).to eq('unknown') + expect(unknown_locked_artifact.reload.locked).to eq('artifacts_locked') + expect(unknown_unlocked_artifact.reload.locked).to eq('unknown') + end + + it 'reports the number of destroyed artifacts' do + is_expected.to eq({ removed: 0, locked: 1 }) + end end - it 'reports the number of destroyed artifacts' do - is_expected.to eq({ removed: 0, locked: 1 }) + context 'when feature flag ci_job_artifacts_backlog_large_loop_limit is disabled' do + before do + stub_feature_flags(ci_job_artifacts_backlog_large_loop_limit: false) + stub_const("#{described_class}::LOOP_LIMIT", 1) + end + + it 'affects the most recently expired artifact first' do + subject + + expect(unknown_locked_artifact.reload.locked).to eq('artifacts_locked') + expect(unknown_unlocked_artifact.reload.locked).to eq('unknown') + end + + it 'reports the number of destroyed artifacts' do + is_expected.to eq({ removed: 0, locked: 1 }) + end end end end