Use geo_secondary_role to set tracking database connection properly

parent 2b1e6a44
class Geo::BaseRegistry < ActiveRecord::Base
self.abstract_class = true
if Gitlab::Geo.configured? && (Gitlab::Geo.secondary? || Rails.env.test?)
if Gitlab::Geo.secondary_role_enabled?
establish_connection Rails.configuration.geo_database
end
end
......@@ -622,6 +622,10 @@ production: &base
# host: localhost
# port: 3808
## GitLab Geo settings (EE-only)
geo_secondary_role:
enable: false
#
# 5. Extra customization
# ==========================
......@@ -705,6 +709,8 @@ test:
user_filter: ''
group_base: 'ou=groups,dc=example,dc=com'
admin_group: ''
geo_secondary_role:
enable: true
staging:
<<: *base
......@@ -342,6 +342,8 @@ Settings.pages['external_https'] ||= false unless Settings.pages['external_http
# Geo
#
Settings.gitlab['geo_status_timeout'] ||= 10
Settings['geo_secondary_role'] ||= Settingslogic.new({})
Settings.geo_secondary_role['enable'] = false if Settings.geo_secondary_role['enable'].nil?
#
# Git LFS
......
if File.exist?(Rails.root.join('config/database_geo.yml'))
if Gitlab::Geo.secondary_role_enabled?
Rails.application.configure do
config.geo_database = config_for(:database_geo)
end
......
......@@ -46,6 +46,10 @@ module Gitlab
Rails.configuration.respond_to?(:geo_database)
end
def self.secondary_role_enabled?
Gitlab.config.geo_secondary_role['enable']
end
def self.license_allows?
::License.current&.feature_available?(:geo)
end
......
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