Commit cd05d08e authored by Nick Thomas's avatar Nick Thomas

Merge branch...

Merge branch '10350-follow-up-from-geo-support-archive-recovery-or-streaming-replication-types' into 'master'

Geo: Support archive recovery or streaming replication types

Closes #10350

See merge request gitlab-org/gitlab-ee!10473
parents f36e9a5b 20795aec
......@@ -34,6 +34,16 @@ module Gitlab
.fetch('replication_lag').to_i
end
def replication_enabled?
streaming_replication_enabled? || archive_recovery_replication_enabled?
end
def replication_working?
return streaming_replication_active? if streaming_replication_enabled?
some_replication_active?
end
private
def db_replication_lag_seconds_query
......@@ -105,10 +115,6 @@ module Gitlab
gitlab_schema_tables_count == foreign_schema_tables_count
end
def replication_enabled?
streaming_replication_enabled? || archive_recovery_replication_enabled?
end
def archive_recovery_replication_enabled?
!streaming_replication_enabled? && some_replication_active?
end
......@@ -133,12 +139,6 @@ module Gitlab
ActiveRecord::Base.connection
.select_values('SELECT pid FROM pg_stat_wal_receiver').first.to_i > 0
end
def replication_working?
return streaming_replication_active? if streaming_replication_enabled?
some_replication_active?
end
end
end
end
......@@ -2,8 +2,8 @@
module SystemCheck
module Geo
class DatabaseReplicationCheck < SystemCheck::BaseCheck
set_name 'Using database streaming replication?'
class DatabaseReplicationEnabledCheck < SystemCheck::BaseCheck
set_name 'Database replication enabled?'
set_skip_reason 'not a secondary node'
def skip?
......@@ -11,16 +11,22 @@ module SystemCheck
end
def check?
Gitlab::Database.db_read_only?
geo_health_check.replication_enabled?
end
def show_error
try_fixing_it(
'Follow Geo setup instructions to configure primary and secondary nodes for streaming replication'
'Follow Geo setup instructions to configure primary and secondary nodes for replication'
)
for_more_information('doc/gitlab-geo/database.md')
end
private
def geo_health_check
@geo_health_check ||= Gitlab::Geo::HealthCheck.new
end
end
end
end
# frozen_string_literal: true
module SystemCheck
module Geo
class DatabaseReplicationWorkingCheck < SystemCheck::BaseCheck
set_name 'Database replication working?'
set_skip_reason 'not a secondary node'
def skip?
!Gitlab::Geo.secondary?
end
def check?
geo_health_check.replication_enabled? && geo_health_check.replication_working?
end
def show_error
try_fixing_it(
'Follow Geo setup instructions to configure primary and secondary nodes for replication'
)
for_more_information('doc/gitlab-geo/database.md')
end
private
def geo_health_check
@geo_health_check ||= Gitlab::Geo::HealthCheck.new
end
end
end
end
......@@ -15,7 +15,8 @@ module SystemCheck
SystemCheck::Geo::LicenseCheck,
SystemCheck::Geo::EnabledCheck,
SystemCheck::Geo::GeoDatabaseConfiguredCheck,
SystemCheck::Geo::DatabaseReplicationCheck,
SystemCheck::Geo::DatabaseReplicationEnabledCheck,
SystemCheck::Geo::DatabaseReplicationWorkingCheck,
SystemCheck::Geo::FdwEnabledCheck,
SystemCheck::Geo::FdwSchemaUpToDateCheck,
SystemCheck::Geo::HttpConnectionCheck,
......
......@@ -2,6 +2,7 @@ require 'spec_helper'
describe Gitlab::Geo::HealthCheck, :geo do
include ::EE::GeoHelpers
using RSpec::Parameterized::TableSyntax
set(:secondary) { create(:geo_node) }
......@@ -176,4 +177,44 @@ describe Gitlab::Geo::HealthCheck, :geo do
end
end
end
describe '#replication_enabled?' do
where(:streaming_replication_enabled, :archive_recovery_replication_enabled, :result) do
false | false | false
true | false | true
false | true | true
end
with_them do
before do
allow(subject).to receive(:streaming_replication_enabled?).and_return(streaming_replication_enabled)
allow(subject).to receive(:archive_recovery_replication_enabled?).and_return(archive_recovery_replication_enabled)
end
it 'returns the correct result' do
expect(subject.replication_enabled?).to eq(result)
end
end
end
describe '#replication_working?' do
where(:streaming_replication_enabled, :streaming_replication_active, :some_replication_active, :result) do
false | nil | false | false
false | nil | true | true
true | false | nil | false
true | true | nil | true
end
with_them do
before do
allow(subject).to receive(:streaming_replication_enabled?).and_return(streaming_replication_enabled)
allow(subject).to receive(:streaming_replication_active?).and_return(streaming_replication_active)
allow(subject).to receive(:some_replication_active?).and_return(some_replication_active)
end
it 'returns the correct result' do
expect(subject.replication_working?).to eq(result)
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