Commit f1b9fc04 authored by Stan Hu's avatar Stan Hu

Suggest a way to resolve Geo tracking DB not having all the migrations

This will help customers resolve the problem on their own.

Also check for PostgreSQL earlier to fix spec.
parent 113666a8
......@@ -2,6 +2,8 @@ module Gitlab
module Geo
class HealthCheck
def self.perform_checks
raise NotImplementedError unless Gitlab::Database.postgresql?
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?
......@@ -11,7 +13,8 @@ module Gitlab
migration_version = self.get_migration_version.to_i
if database_version != migration_version
"Current Geo database version (#{database_version}) does not match latest migration (#{migration_version})."
"Current Geo database version (#{database_version}) does not match latest migration (#{migration_version}).\n"\
"You may have to run `gitlab-rake geo:db:migrate` as root on the secondary."
else
''
end
......
......@@ -10,6 +10,20 @@ describe Gitlab::Geo::HealthCheck do
skip("Not using PostgreSQL") unless Gitlab::Database.postgresql?
end
it 'returns a string if database is not fully migrated' do
allow(Gitlab::Geo).to receive(:secondary?) { true }
allow(Gitlab::Geo).to receive(:secondary_role_enabled?).and_return(true)
allow(described_class).to receive(:geo_database_configured?).and_return(true)
allow(described_class).to receive(:database_secondary?).and_return(true)
allow(described_class).to receive(:get_database_version).and_return('20170101')
allow(described_class).to receive(:get_migration_version).and_return('20170201')
message = subject.perform_checks
expect(message).to include('Current Geo database version (20170101) does not match latest migration (20170201)')
expect(message).to include('gitlab-rake geo:db:migrate')
end
it 'returns an empty string when not running on a secondary node' do
allow(Gitlab::Geo).to receive(:secondary?) { false }
......
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