Use geo_secondary_role to set tracking database connection properly

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