Fix Elastic check deprecation warning about gem version (#27262)

pull/25656/head
Matt Jankowski 2023-10-03 09:52:47 -04:00 committed by GitHub
parent 85db392464
commit 2f8f92df48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 25 additions and 4 deletions

View File

@ -76,14 +76,35 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
end end
def compatible_version? def compatible_version?
return false if running_version.nil? running_version_ok? || compatible_wire_version_ok?
Gem::Version.new(running_version) >= Gem::Version.new(required_version) ||
Gem::Version.new(compatible_wire_version) >= Gem::Version.new(required_version)
rescue ArgumentError rescue ArgumentError
false false
end end
def running_version_ok?
return false if running_version.blank?
gem_version_running >= gem_version_required
end
def compatible_wire_version_ok?
return false if compatible_wire_version.blank?
gem_version_compatible_wire >= gem_version_required
end
def gem_version_running
Gem::Version.new(running_version)
end
def gem_version_required
Gem::Version.new(required_version)
end
def gem_version_compatible_wire
Gem::Version.new(compatible_wire_version)
end
def mismatched_indexes def mismatched_indexes
@mismatched_indexes ||= INDEXES.filter_map do |klass| @mismatched_indexes ||= INDEXES.filter_map do |klass|
klass.base_name if Chewy.client.indices.get_mapping[klass.index_name]&.deep_symbolize_keys != klass.mappings_hash klass.base_name if Chewy.client.indices.get_mapping[klass.index_name]&.deep_symbolize_keys != klass.mappings_hash