Commit 92da9fc2 authored by Quang-Minh Nguyen's avatar Quang-Minh Nguyen

Remove mirror_scheduling_track feature flag

This flag was introduced in
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81249 and rolled
out in https://gitlab.com/gitlab-org/gitlab/-/issues/353440
parent 32293539
---
name: mirror_scheduling_tracking
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/81249
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/353440
milestone: '14.9'
type: development
group: group::scalability
default_enabled: false
......@@ -21,7 +21,7 @@ class ProjectImportScheduleWorker
tags :needs_own_queue
def perform(project_id)
::Gitlab::Mirror.untrack_scheduling(project_id) if scheduling_tracking_enabled?
::Gitlab::Mirror.untrack_scheduling(project_id)
return if Gitlab::Database.read_only?
......@@ -32,10 +32,4 @@ class ProjectImportScheduleWorker
project.import_state.schedule
end
end
private
def scheduling_tracking_enabled?
Feature.enabled?(:mirror_scheduling_tracking, default_enabled: :yaml)
end
end
......@@ -50,7 +50,7 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
# Therefore, the scheduling counter should reset the counter before entering
# the scheduling phase. In addition, this clean-up task prevents a project
# id from being stuck in the list forever.
::Gitlab::Mirror.reset_scheduling if scheduling_tracking_enabled?
::Gitlab::Mirror.reset_scheduling
capacity = Gitlab::Mirror.available_capacity
......@@ -144,7 +144,7 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
return if projects.empty?
# projects were materialized at this stage
::Gitlab::Mirror.track_scheduling(projects.map(&:id)) if scheduling_tracking_enabled?
::Gitlab::Mirror.track_scheduling(projects.map(&:id))
ProjectImportScheduleWorker.bulk_perform_async_with_contexts(
projects,
......@@ -168,14 +168,6 @@ class UpdateAllMirrorsWorker # rubocop:disable Scalability/IdempotentWorker
# rubocop: enable CodeReuse/ActiveRecord
def pending_project_import_scheduling?
if scheduling_tracking_enabled?
::Gitlab::Mirror.current_scheduling > 0
else
ProjectImportScheduleWorker.queue_size > 0
end
end
def scheduling_tracking_enabled?
Feature.enabled?(:mirror_scheduling_tracking, default_enabled: :yaml)
::Gitlab::Mirror.current_scheduling > 0
end
end
......@@ -35,28 +35,10 @@ RSpec.describe ProjectImportScheduleWorker do
expect(import_state).to be_scheduled
end
context 'mirror_scheduling_tracking flag is enabled' do
before do
stub_feature_flags(mirror_scheduling_tracking: true)
end
it 'tracks the status of the worker' do
subject
expect(Gitlab::Mirror).to have_received(:untrack_scheduling).with(project.id).at_least(:once)
end
end
context 'mirror_scheduling_tracking flag is disabled' do
before do
stub_feature_flags(mirror_scheduling_tracking: false)
end
it 'does not track the status of the worker' do
subject
it 'tracks the status of the worker' do
subject
expect(Gitlab::Mirror).not_to have_received(:untrack_scheduling)
end
expect(Gitlab::Mirror).to have_received(:untrack_scheduling).with(project.id).at_least(:once)
end
end
......
......@@ -62,42 +62,16 @@ RSpec.describe UpdateAllMirrorsWorker do
allow(Gitlab::Mirror).to receive(:current_scheduling) { |_| count -= 1 }
end
context 'mirror_scheduling_tracking flags is on' do
before do
stub_feature_flags(mirror_scheduling_tracking: true)
end
it 'waits until ProjectImportScheduleWorker job tracker returns 0' do
worker.perform
expect(Gitlab::Mirror).to have_received(:current_scheduling).exactly(3).times
end
it 'sleeps a bit after scheduling mirrors' do
expect(worker).to receive(:sleep).with(described_class::RESCHEDULE_WAIT).exactly(3).times
it 'waits until ProjectImportScheduleWorker job tracker returns 0' do
worker.perform
worker.perform
end
expect(Gitlab::Mirror).to have_received(:current_scheduling).exactly(3).times
end
context 'mirror_scheduling_tracking flags is off' do
before do
stub_feature_flags(mirror_scheduling_tracking: false)
count = 3
allow(ProjectImportScheduleWorker).to receive(:queue_size) { |_| count -= 1 }
end
it 'waits until ProjectImportScheduleWorker jobs to complete' do
worker.perform
expect(ProjectImportScheduleWorker).to have_received(:queue_size).exactly(3).times
end
it 'sleeps a bit after scheduling mirrors' do
expect(worker).to receive(:sleep).with(described_class::RESCHEDULE_WAIT).exactly(3).times
it 'sleeps a bit after scheduling mirrors' do
expect(worker).to receive(:sleep).with(described_class::RESCHEDULE_WAIT).exactly(3).times
worker.perform
end
worker.perform
end
context 'if capacity is available' do
......
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