Try to establish connection to the Geo DB only if config file is present

parent 407036f4
class Geo::BaseRegistry < ActiveRecord::Base
self.abstract_class = true
if Gitlab::Geo.secondary_role_enabled?
if Gitlab::Geo.secondary_role_enabled? && Gitlab::Geo.geo_database_configured?
establish_connection Rails.configuration.geo_database
end
end
......@@ -50,6 +50,10 @@ module Gitlab
Gitlab.config.geo_secondary_role['enabled']
end
def self.geo_database_configured?
Rails.configuration.respond_to?(:geo_database)
end
def self.license_allows?
::License.feature_available?(:geo)
end
......
......@@ -6,7 +6,7 @@ module Gitlab
return '' unless Gitlab::Geo.secondary?
return 'The Geo secondary role is disabled.' unless Gitlab::Geo.secondary_role_enabled?
return 'The Geo database configuration file is missing.' unless self.geo_database_configured?
return 'The Geo database configuration file is missing.' unless Gitlab::Geo.geo_database_configured?
return 'The Geo node has a database that is not configured for streaming replication with the primary node.' unless self.database_secondary?
database_version = self.get_database_version.to_i
......@@ -61,10 +61,6 @@ module Gitlab
.first
.fetch('pg_is_in_recovery') == 't'
end
def self.geo_database_configured?
Rails.configuration.respond_to?(:geo_database)
end
end
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