Commit b339a870 authored by Douwe Maan's avatar Douwe Maan

Merge branch 'extra-geo-checks' into 'master'

Geo: Added extra SystemCheck checks

Closes #2860 and #2469

See merge request !2354
parents 3b5928de 9f8ff5ce
......@@ -394,6 +394,9 @@ gem 'health_check', '~> 2.6.0'
gem 'vmstat', '~> 2.3.0'
gem 'sys-filesystem', '~> 1.1.6'
# NTP client
gem 'net-ntp'
# Gitaly GRPC client
gem 'gitaly', '~> 0.9.0'
......
......@@ -503,6 +503,7 @@ GEM
mustermann (= 0.4.0)
mysql2 (0.4.5)
net-ldap (0.12.1)
net-ntp (2.1.3)
net-ssh (3.0.1)
netrc (0.11.0)
nokogiri (1.6.8.1)
......@@ -1053,6 +1054,7 @@ DEPENDENCIES
mousetrap-rails (~> 1.4.6)
mysql2 (~> 0.4.5)
net-ldap
net-ntp
net-ssh (~> 3.0.1)
nokogiri (~> 1.6.7, >= 1.6.7.2)
oauth2 (~> 1.4)
......
---
title: 'Geo: Added extra SystemCheck checks'
merge_request: 2354
author:
module SystemCheck
module Geo
class ClocksSynchronizationCheck < SystemCheck::BaseCheck
set_name 'Machine clock is synchronized'
def check?
Net::NTP.get.offset.abs < Gitlab::Geo::JwtRequestDecoder::IAT_LEEWAY
end
def show_error
try_fixing_it(
'Enable a NTP service on this machine to keep clocks synchronized'
)
end
end
end
end
module SystemCheck
module Geo
class DatabaseReplicationCheck < SystemCheck::BaseCheck
set_name 'Using database streaming replication?'
set_skip_reason 'not a secondary node'
def skip?
!Gitlab::Geo.secondary?
end
def check?
ActiveRecord::Base.connection.execute('SELECT pg_is_in_recovery()').first.fetch('pg_is_in_recovery') == 't'
end
def show_error
try_fixing_it(
'Follow Geo setup instructions to configure primary and secondary nodes for streaming replication'
)
for_more_information('doc/gitlab-geo/database.md')
end
end
end
end
module SystemCheck
module Geo
class GeoDatabaseConfiguredCheck < SystemCheck::BaseCheck
set_name 'GitLab Geo secondary database is correctly configured'
set_skip_reason 'not a secondary node'
def skip?
!Gitlab::Geo.secondary?
end
def check?
Gitlab::Geo.geo_database_configured?
end
def show_error
try_fixing_it(
'Check if you enabled the `geo_secondary_role` or `geo_postgresql` in the gitlab.rb config file.'
)
for_more_information('doc/gitlab-geo/database.md')
end
end
end
end
......@@ -42,7 +42,7 @@ module SystemCheck
#
# @param [SystemCheck::BaseCheck] check_klass
def run_check(check_klass)
$stdout.print "#{check_klass.display_name} ... "
print_display_name(check_klass)
check = check_klass.new
......@@ -59,17 +59,17 @@ module SystemCheck
end
if check.check?
$stdout.puts check_klass.check_pass.color(:green)
print_check_pass(check_klass)
else
$stdout.puts check_klass.check_fail.color(:red)
print_check_failure(check_klass)
if check.can_repair?
$stdout.print 'Trying to fix error automatically. ...'
if check.repair!
$stdout.puts 'Success'.color(:green)
print_success
return
else
$stdout.puts 'Failed'.color(:red)
print_failure
end
end
......@@ -81,6 +81,26 @@ module SystemCheck
private
def print_display_name(check_klass)
$stdout.print "#{check_klass.display_name} ... "
end
def print_check_pass(check_klass)
$stdout.puts check_klass.check_pass.color(:green)
end
def print_check_failure(check_klass)
$stdout.puts check_klass.check_fail.color(:red)
end
def print_success
$stdout.puts 'Success'.color(:green)
end
def print_failure
$stdout.puts 'Failed'.color(:red)
end
# Prints header content for the series of checks to be executed for this component
#
# @param [String] component name of the component relative to the checks being executed
......
......@@ -549,7 +549,10 @@ namespace :gitlab do
checks = [
SystemCheck::Geo::LicenseCheck,
SystemCheck::Geo::EnabledCheck,
SystemCheck::Geo::HttpConnectionCheck
SystemCheck::Geo::GeoDatabaseConfiguredCheck,
SystemCheck::Geo::DatabaseReplicationCheck,
SystemCheck::Geo::HttpConnectionCheck,
SystemCheck::Geo::ClocksSynchronizationCheck
]
SystemCheck.run('Geo', checks)
......
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