Commit 6bba487b authored by Valery Sizov's avatar Valery Sizov

Fix "Geo: PagesDomainVerificationWorker can start up on secondaries if DB is down"

parent 0c16b08b
......@@ -21,9 +21,11 @@ module Gitlab
CONFIG_WATCHER_CLASS = 'Geo::SidekiqCronConfigWorker'.freeze
def execute
if Geo.connected? && Geo.primary?
return unless Geo.connected?
if Geo.primary?
configure_primary
elsif Geo.connected? && Geo.secondary?
elsif Geo.secondary?
configure_secondary
else
enable!(all_jobs(except: GEO_JOBS))
......
......@@ -23,6 +23,10 @@ describe Gitlab::Geo::CronManager, :geo do
job.enable!
end
def count_enabled
JOBS.count { |job_name| job(job_name).enabled? }
end
JOBS = %w[
ldap_test
geo_repository_verification_primary_batch_worker
......@@ -77,6 +81,14 @@ describe Gitlab::Geo::CronManager, :geo do
it 'enables non-geo jobs' do
expect(ldap_test_job).to be_enabled
end
context 'No connection' do
it 'does not change current job configuration' do
allow(Geo).to receive(:connected?).and_return(false)
expect { manager.execute }.not_to change { count_enabled }
end
end
end
context 'on a Geo secondary' 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