Commit 3c562211 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Use `geo_database_configured?` instead of `secondary_role_enabled?`

parent bbeeaad3
class Geo::BaseRegistry < ActiveRecord::Base class Geo::BaseRegistry < ActiveRecord::Base
self.abstract_class = true self.abstract_class = true
if Gitlab::Geo.secondary_role_enabled? && Gitlab::Geo.geo_database_configured? if Gitlab::Geo.geo_database_configured?
establish_connection Rails.configuration.geo_database establish_connection Rails.configuration.geo_database
end end
......
...@@ -22,7 +22,7 @@ class GeoFileDownloadDispatchWorker ...@@ -22,7 +22,7 @@ class GeoFileDownloadDispatchWorker
# files, excluding ones in progress. # files, excluding ones in progress.
# 5. Quit when we have scheduled all downloads or exceeded an hour. # 5. Quit when we have scheduled all downloads or exceeded an hour.
def perform def perform
return unless Gitlab::Geo.secondary_role_enabled? return unless Gitlab::Geo.geo_database_configured?
return unless Gitlab::Geo.secondary? return unless Gitlab::Geo.secondary?
@start_time = Time.now @start_time = Time.now
......
...@@ -15,7 +15,7 @@ class GeoRepositorySyncWorker ...@@ -15,7 +15,7 @@ class GeoRepositorySyncWorker
end end
def perform def perform
return unless Gitlab::Geo.secondary_role_enabled? return unless Gitlab::Geo.geo_database_configured?
return unless Gitlab::Geo.primary_node.present? return unless Gitlab::Geo.primary_node.present?
logger.info "Started Geo repository sync scheduler" logger.info "Started Geo repository sync scheduler"
......
if File.exist?(Rails.root.join('config/database_geo.yml')) && if File.exist?(Rails.root.join('config/database_geo.yml'))
Gitlab::Geo.secondary_role_enabled?
Rails.application.configure do Rails.application.configure do
config.geo_database = config_for(:database_geo) config.geo_database = config_for(:database_geo)
end end
......
...@@ -34,7 +34,7 @@ RSpec.configure do |config| ...@@ -34,7 +34,7 @@ RSpec.configure do |config|
end end
def setup_database_cleaner def setup_database_cleaner
if Gitlab::Geo.secondary_role_enabled? if Gitlab::Geo.geo_database_configured?
DatabaseCleaner[:active_record, { connection: Geo::BaseRegistry }] DatabaseCleaner[:active_record, { connection: Geo::BaseRegistry }]
end end
......
...@@ -16,7 +16,7 @@ describe GeoFileDownloadDispatchWorker do ...@@ -16,7 +16,7 @@ describe GeoFileDownloadDispatchWorker do
it 'does not schedule anything when secondary role is disabled' do it 'does not schedule anything when secondary role is disabled' do
create(:lfs_object, :with_file) create(:lfs_object, :with_file)
allow(Gitlab::Geo).to receive(:secondary_role_enabled?) { false } allow(Gitlab::Geo).to receive(:geo_database_configured?) { false }
expect(GeoFileDownloadWorker).not_to receive(:perform_async) expect(GeoFileDownloadWorker).not_to receive(:perform_async)
......
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