Commit c2e52a68 authored by Sean McGivern's avatar Sean McGivern

Merge branch...

Merge branch '5431-geo-pagesdomainverificationworker-can-start-up-on-secondaries-if-db-is-down' into 'master'

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

Closes #5431

See merge request gitlab-org/gitlab-ee!5182
parents ab3b13f7 8d3a9477
---
title: 'Ensure Geo secondary nodes only run cron jobs appropriate for secondaries'
merge_request:
author:
type: fixed
......@@ -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