Commit c09ad191 authored by Gabriel Mazetto's avatar Gabriel Mazetto

Refactor Elasticsearch checks to SystemCheck

parent 7b164cb7
module SystemCheck
module App
class ElasticsearchCheck < SystemCheck::BaseCheck
set_name 'Elasticsearch version 5.1 - 5.3?'
set_skip_reason 'skipped (elasticsearch is disabled)'
set_check_pass -> { "yes (#{self.current_version})" }
set_check_fail -> { "no (#{self.current_version})" }
def self.current_version
@current_version ||= begin
client = Gitlab::Elastic::Client.build(current_application_settings.elasticsearch_config)
Gitlab::VersionInfo.parse(client.info['version']['number'])
end
end
def skip?
!current_application_settings.elasticsearch_indexing?
end
def check?
current_version.major == 5 && (1..3).cover?(version.minor)
end
end
end
end
......@@ -33,11 +33,11 @@ namespace :gitlab do
SystemCheck::App::RedisVersionCheck,
SystemCheck::App::RubyVersionCheck,
SystemCheck::App::GitVersionCheck,
SystemCheck::App::ActiveUsersCheck
SystemCheck::App::ActiveUsersCheck,
SystemCheck::App::ElasticsearchCheck
]
SystemCheck.run('GitLab', checks)
check_elasticsearch if current_application_settings.elasticsearch_indexing?
end
end
......@@ -661,20 +661,6 @@ namespace :gitlab do
end
end
def check_elasticsearch
client = Gitlab::Elastic::Client.build(current_application_settings.elasticsearch_config)
print "Elasticsearch version 5.1 - 5.3? ... "
version = Gitlab::VersionInfo.parse(client.info["version"]["number"])
if version.major == 5 && (1..3).cover?(version.minor)
puts "yes (#{version})".color(:green)
else
puts "no, you have #{version}".color(:red)
end
end
def check_gitlab_geo_node(node)
display_error = proc do |e|
puts 'no'.color(:red)
......
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