Commit d14fff92 authored by Robert Speicher's avatar Robert Speicher

Merge branch 'sh-geo-add-migration-help-message' into 'master'

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

See merge request !2100
parents 113666a8 9deaf60d
......@@ -6,6 +6,8 @@ class GeoNodeStatus
def health
@health ||= HealthCheck::Utils.process_checks(['geo'])
rescue NotImplementedError => e
@health = e.to_s
end
def healthy?
......
......@@ -2,6 +2,8 @@ module Gitlab
module Geo
class HealthCheck
def self.perform_checks
raise NotImplementedError.new('Geo is only compatible with PostgreSQL') 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
......
require 'spec_helper'
describe Admin::GeoNodesController do
describe Admin::GeoNodesController, :postgresql do
shared_examples 'unlicensed geo action' do
it 'redirects to the license page' do
expect(response).to redirect_to(admin_license_path)
......
require 'spec_helper'
describe Gitlab::Geo::HealthCheck do
describe Gitlab::Geo::HealthCheck, :postgresql do
let!(:secondary) { create(:geo_node, :current) }
subject { described_class }
describe '.perform_checks' do
before do
skip("Not using PostgreSQL") unless Gitlab::Database.postgresql?
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
......
require 'spec_helper'
describe GeoNodeStatusEntity do
describe GeoNodeStatusEntity, :postgresql do
let(:geo_node_status) do
GeoNodeStatus.new(
id: 1,
......
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