Commit e0f5dc24 authored by Sean McGivern's avatar Sean McGivern

Merge branch 'qmnguyen0711/remove-mirroring-scheduling-tracker' into 'master'

Remove mirror_scheduling_tracker and ProjectImporScheduleWorker's needs_own_queue tag

See merge request gitlab-org/gitlab!81960
parents 55cad6a2 5261a567
---
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
......@@ -1235,8 +1235,7 @@
:resource_boundary: :unknown
:weight: 1
:idempotent: true
:tags:
- :needs_own_queue
:tags: []
- :name: project_template_export
:worker_name: ProjectTemplateExportWorker
:feature_category: :importers
......
......@@ -16,12 +16,8 @@ class ProjectImportScheduleWorker
loggable_arguments 1 # For the job waiter key
log_bulk_perform_async!
# UpdateAllMirrorsWorker depends on the queue size of this worker:
# https://gitlab.com/gitlab-org/gitlab/-/issues/340630
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 +28,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