This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
2022-03-25 13:00:59 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
|
2022-07-04 17:41:40 -07:00
|
|
|
def skip?
|
|
|
|
!current_user.can?(:view_devops)
|
|
|
|
end
|
|
|
|
|
2022-03-25 13:00:59 -07:00
|
|
|
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 required_version
|
|
|
|
'7.x'
|
|
|
|
end
|
|
|
|
|
|
|
|
def compatible_version?
|
2022-12-15 06:56:48 -08:00
|
|
|
return false if running_version.nil?
|
2022-03-25 13:00:59 -07:00
|
|
|
Gem::Version.new(running_version) >= Gem::Version.new(required_version)
|
|
|
|
end
|
|
|
|
end
|