Commit 7e10cba4 authored by Michael Kozono's avatar Michael Kozono

Merge branch '223254-remove-fdw-health-checks' into 'master'

Geo - Remove FDW health checks

See merge request gitlab-org/gitlab!38620
parents bd812df5 4c82ce09
---
title: 'Geo: Remove FDW warnings from health checks'
merge_request: 38620
author:
type: removed
...@@ -56,10 +56,6 @@ module Gitlab ...@@ -56,10 +56,6 @@ module Gitlab
end end
end end
def gitlab_schema_tables_count
ActiveRecord::Schema.tables.reject { |table| table.start_with?('pg_') }.count
end
def expire_cache! def expire_cache!
Gitlab::Geo.expire_cache_keys!(CACHE_KEYS) Gitlab::Geo.expire_cache_keys!(CACHE_KEYS)
end end
......
...@@ -12,13 +12,6 @@ module Gitlab ...@@ -12,13 +12,6 @@ module Gitlab
return 'Geo node has a database that is writable which is an indication it is not configured for replication with the primary node.' unless Gitlab::Database.db_read_only? return 'Geo node has a database that is writable which is an indication it is not configured for replication with the primary node.' unless Gitlab::Database.db_read_only?
return 'Geo node does not appear to be replicating the database from the primary node.' if replication_enabled? && !replication_working? return 'Geo node does not appear to be replicating the database from the primary node.' if replication_enabled? && !replication_working?
return "Geo database version (#{database_version}) does not match latest migration (#{migration_version}).\nYou may have to run `gitlab-rake geo:db:migrate` as root on the secondary." unless database_migration_version_match? return "Geo database version (#{database_version}) does not match latest migration (#{migration_version}).\nYou may have to run `gitlab-rake geo:db:migrate` as root on the secondary." unless database_migration_version_match?
return 'Geo database is not configured to use Foreign Data Wrapper.' unless Gitlab::Geo::Fdw.enabled?
unless Gitlab::Geo::Fdw.foreign_tables_up_to_date?
output = "Geo database has an outdated FDW remote schema."
output = "#{output} It contains #{foreign_schema_tables_count} of #{gitlab_schema_tables_count} expected tables." unless schema_tables_match?
return output
end
'' ''
rescue => e rescue => e
...@@ -109,18 +102,6 @@ module Gitlab ...@@ -109,18 +102,6 @@ module Gitlab
database_version.to_i == migration_version.to_i database_version.to_i == migration_version.to_i
end end
def gitlab_schema_tables_count
@gitlab_schema_tables_count ||= Gitlab::Geo::Fdw.gitlab_schema_tables_count
end
def foreign_schema_tables_count
@foreign_schema_tables_count ||= Gitlab::Geo::Fdw.foreign_schema_tables_count
end
def schema_tables_match?
gitlab_schema_tables_count == foreign_schema_tables_count
end
def archive_recovery_replication_enabled? def archive_recovery_replication_enabled?
!streaming_replication_enabled? && some_replication_active? !streaming_replication_enabled? && some_replication_active?
end end
......
...@@ -138,20 +138,6 @@ RSpec.describe Gitlab::Geo::Fdw, :geo do ...@@ -138,20 +138,6 @@ RSpec.describe Gitlab::Geo::Fdw, :geo do
end end
end end
describe '.gitlab_schema_tables_count' do
it 'returns the same number of tables as defined in the database' do
expect(described_class.gitlab_schema_tables_count).to eq(ActiveRecord::Schema.tables.count)
end
it 'excludes tables that start with `pg_`' do
ActiveRecord::Base.connection.create_table(:pg_gitlab_test)
expect(described_class.gitlab_schema_tables_count).to eq(ActiveRecord::Schema.tables.count - 1)
ActiveRecord::Base.connection.drop_table(:pg_gitlab_test)
end
end
describe '.expire_cache!' do describe '.expire_cache!' do
it 'calls Gitlab::Geo.expire_cache_keys!' do it 'calls Gitlab::Geo.expire_cache_keys!' do
expect(Gitlab::Geo).to receive(:expire_cache_keys!).with(Gitlab::Geo::Fdw::CACHE_KEYS) expect(Gitlab::Geo).to receive(:expire_cache_keys!).with(Gitlab::Geo::Fdw::CACHE_KEYS)
......
...@@ -102,8 +102,6 @@ RSpec.describe Gitlab::Geo::HealthCheck, :geo do ...@@ -102,8 +102,6 @@ RSpec.describe Gitlab::Geo::HealthCheck, :geo do
context 'that is working' do context 'that is working' do
before do before do
allow(subject).to receive(:replication_working?).and_return(true) allow(subject).to receive(:replication_working?).and_return(true)
allow(Gitlab::Geo::Fdw).to receive(:enabled?) { true }
allow(Gitlab::Geo::Fdw).to receive(:foreign_tables_up_to_date?) { true }
end end
it 'returns an error if database is not fully migrated' do it 'returns an error if database is not fully migrated' do
...@@ -116,32 +114,6 @@ RSpec.describe Gitlab::Geo::HealthCheck, :geo do ...@@ -116,32 +114,6 @@ RSpec.describe Gitlab::Geo::HealthCheck, :geo do
expect(message).to include('gitlab-rake geo:db:migrate') expect(message).to include('gitlab-rake geo:db:migrate')
end end
it 'returns an error when FDW is disabled' do
allow(Gitlab::Geo::Fdw).to receive(:enabled?) { false }
expect(subject.perform_checks).to match(/Geo database is not configured to use Foreign Data Wrapper/)
end
context 'when foreign tables are not up-to-date' do
before do
allow(Gitlab::Geo::Fdw).to receive(:foreign_tables_up_to_date?) { false }
end
it 'returns an error when FDW remote table is not in sync but has same amount of tables' do
allow(Gitlab::Geo::Fdw).to receive(:foreign_schema_tables_count) { 1 }
allow(Gitlab::Geo::Fdw).to receive(:gitlab_schema_tables_count) { 1 }
expect(subject.perform_checks).to match(/Geo database has an outdated FDW remote schema\./)
end
it 'returns an error when FDW remote table is not in sync and has same different amount of tables' do
allow(Gitlab::Geo::Fdw).to receive(:foreign_schema_tables_count) { 1 }
allow(Gitlab::Geo::Fdw).to receive(:gitlab_schema_tables_count) { 2 }
expect(subject.perform_checks).to match(/Geo database has an outdated FDW remote schema\. It contains [0-9]+ of [0-9]+ expected tables/)
end
end
it 'finally returns an empty string when everything is healthy' do it 'finally returns an empty string when everything is healthy' do
expect(subject.perform_checks).to be_blank expect(subject.perform_checks).to be_blank
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