blob: 5b4c12399b887886040d7a932c347eadbfe159ca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# frozen_string_literal: true
class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
def skip?
!current_user.can?(:view_devops)
end
def pass?
return true unless Chewy.enabled?
running_version.present? && compatible_version?
end
def message
if running_version.present?
Admin::SystemCheck::Message.new(
:elasticsearch_version_check,
I18n.t(
'admin.system_checks.elasticsearch_version_check.version_comparison',
running_version: running_version,
required_version: required_version
)
)
else
Admin::SystemCheck::Message.new(:elasticsearch_running_check)
end
end
private
def running_version
@running_version ||= begin
Chewy.client.info['version']['number']
rescue Faraday::ConnectionFailed
nil
end
end
def compatible_wire_version
Chewy.client.info['version']['minimum_wire_compatibility_version']
end
def required_version
'7.x'
end
def compatible_version?
return false if running_version.nil?
Gem::Version.new(running_version) >= Gem::Version.new(required_version) ||
Gem::Version.new(compatible_wire_version) >= Gem::Version.new(required_version)
end
end
|