Commit a0b8e5eb authored by Nick Thomas's avatar Nick Thomas

Fix an exception in Geo scheduler workers

parent 4ccac676
......@@ -124,6 +124,8 @@ module Geo
def schedule_jobs
capacity = max_capacity
num_to_schedule = [capacity - scheduled_job_ids.size, pending_resources.size].min
num_to_schedule = 0 if num_to_schedule < 0
to_schedule = pending_resources.shift(num_to_schedule)
scheduled = to_schedule.map do |args|
......
---
title: Fix an exception in Geo scheduler workers
merge_request: 3740
author:
type: fixed
......@@ -175,6 +175,15 @@ describe Geo::RepositoryShardSyncWorker, :geo, :delete, :clean_gitlab_redis_cach
Sidekiq::Testing.inline! { subject.perform(shard_name) }
end
end
context 'number of scheduled jobs exceeds capacity' do
it 'schedules 0 jobs' do
is_expected.to receive(:scheduled_job_ids).and_return(1..1000).at_least(:once)
is_expected.not_to receive(:schedule_job)
Sidekiq::Testing.inline! { subject.perform(shard_name) }
end
end
end
describe 'when PostgreSQL FDW is available', :geo 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