Commit f7428fac authored by Michael Kozono's avatar Michael Kozono

Merge branch 'cat-fix-geo-session-route-initialization' into 'master'

Fix DB connection check for Geo user routing

See merge request gitlab-org/gitlab!70621
parents ed2daff7 f908364d
......@@ -44,7 +44,11 @@ module Gitlab
end
def self.connected?
GeoNode.connected? && GeoNode.table_exists?
# GeoNode#connected? only attempts to use existing DB connections so it can't
# be relied upon in initializers, without this active DB connectivity check.
active_db_connection = GeoNode.connection_pool.with_connection(&:active?) rescue false
active_db_connection && GeoNode.table_exists?
end
def self.enabled?
......
......@@ -165,8 +165,8 @@ RSpec.describe Gitlab::Geo, :geo, :request_store do
describe '.connected?' do
context 'when there is a database issue' do
it 'returns false when database connection is down' do
allow(GeoNode).to receive(:connected?) { false }
it 'returns false when it cannot open an active database connection' do
allow(GeoNode.connection).to receive(:active?).and_return(false)
expect(described_class.connected?).to be_falsey
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