Use Geo roles to configure Sidekiq cron jobs

parent 340b2f79
......@@ -623,6 +623,8 @@ production: &base
# port: 3808
## GitLab Geo settings (EE-only)
geo_primary_role:
enable: false
geo_secondary_role:
enable: false
......@@ -709,6 +711,8 @@ test:
user_filter: ''
group_base: 'ou=groups,dc=example,dc=com'
admin_group: ''
geo_primary_role:
enable: true
geo_secondary_role:
enable: true
......
......@@ -342,6 +342,8 @@ Settings.pages['external_https'] ||= false unless Settings.pages['external_http
# Geo
#
Settings.gitlab['geo_status_timeout'] ||= 10
Settings['geo_primary_role'] ||= Settingslogic.new({})
Settings.geo_primary_role['enable'] = false if Settings.geo_primary_role['enable'].nil?
Settings['geo_secondary_role'] ||= Settingslogic.new({})
Settings.geo_secondary_role['enable'] = false if Settings.geo_secondary_role['enable'].nil?
......
......@@ -46,6 +46,10 @@ module Gitlab
Rails.configuration.respond_to?(:geo_database)
end
def self.primary_role_enabled?
Gitlab.config.geo_primary_role['enable']
end
def self.secondary_role_enabled?
Gitlab.config.geo_secondary_role['enable']
end
......@@ -98,9 +102,9 @@ module Gitlab
end
def self.configure_cron_jobs!
if self.primary?
if self.primary_role_enabled?
self.configure_primary_jobs!
elsif self.secondary?
elsif self.secondary_role_enabled?
self.configure_secondary_jobs!
else
self.disable_all_jobs!
......
......@@ -127,7 +127,9 @@ describe Gitlab::Geo, lib: true do
end
it 'activates cron jobs for primary' do
allow(described_class).to receive(:primary?).and_return(true)
allow(described_class).to receive(:primary_role_enabled?).and_return(true)
allow(described_class).to receive(:secondary_role_enabled?).and_return(false)
described_class.configure_cron_jobs!
expect(described_class.bulk_notify_job).to be_enabled
......@@ -136,7 +138,9 @@ describe Gitlab::Geo, lib: true do
end
it 'activates cron jobs for secondary' do
allow(described_class).to receive(:secondary?).and_return(true)
allow(described_class).to receive(:primary_role_enabled?).and_return(false)
allow(described_class).to receive(:secondary_role_enabled?).and_return(true)
described_class.configure_cron_jobs!
expect(described_class.bulk_notify_job).not_to be_enabled
......@@ -145,6 +149,9 @@ describe Gitlab::Geo, lib: true do
end
it 'deactivates all jobs when Geo is not active' do
allow(described_class).to receive(:primary_role_enabled?).and_return(false)
allow(described_class).to receive(:secondary_role_enabled?).and_return(false)
described_class.configure_cron_jobs!
expect(described_class.bulk_notify_job).not_to be_enabled
......
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