Add admin dashboard checks for Elasticsearch version (#17863)

This commit is contained in:
Claire 2022-03-25 21:00:59 +01:00 committed by GitHub
parent b58db8f12e
commit f65eaa5aae
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 45 additions and 0 deletions

View File

@ -5,6 +5,7 @@ class Admin::SystemCheck
Admin::SystemCheck::DatabaseSchemaCheck, Admin::SystemCheck::DatabaseSchemaCheck,
Admin::SystemCheck::SidekiqProcessCheck, Admin::SystemCheck::SidekiqProcessCheck,
Admin::SystemCheck::RulesCheck, Admin::SystemCheck::RulesCheck,
Admin::SystemCheck::ElasticsearchCheck,
].freeze ].freeze
def self.perform def self.perform

View File

@ -0,0 +1,39 @@
# frozen_string_literal: true
class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
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?
Gem::Version.new(running_version) >= Gem::Version.new(required_version)
end
def missing_queues
@missing_queues ||= Sidekiq::ProcessSet.new.reduce(SIDEKIQ_QUEUES) { |queues, process| queues - process['queues'] }
end
end

View File

@ -780,6 +780,11 @@ en:
message_html: You haven't defined any server rules. message_html: You haven't defined any server rules.
sidekiq_process_check: sidekiq_process_check:
message_html: No Sidekiq process running for the %{value} queue(s). Please review your Sidekiq configuration message_html: No Sidekiq process running for the %{value} queue(s). Please review your Sidekiq configuration
elasticsearch_running_check:
message_html: Could not connect to Elasticsearch. Please check that it is running, or disable full-text search
elasticsearch_version_check:
message_html: "Incompatible Elasticsearch version: %{value}"
version_comparison: "Elasticsearch %{running_version} is running while %{required_version} is required"
tags: tags:
review: Review status review: Review status
updated_msg: Hashtag settings updated successfully updated_msg: Hashtag settings updated successfully