Add warning for Elasticsearch index analyzers mismatch (#34515)
This commit is contained in:
		@@ -38,6 +38,11 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
 | 
			
		||||
        :elasticsearch_index_mismatch,
 | 
			
		||||
        mismatched_indexes.join(' ')
 | 
			
		||||
      )
 | 
			
		||||
    elsif !specifications_match?
 | 
			
		||||
      Admin::SystemCheck::Message.new(
 | 
			
		||||
        :elasticsearch_analysis_mismatch,
 | 
			
		||||
        mismatched_specifications_indexes.join(' ')
 | 
			
		||||
      )
 | 
			
		||||
    elsif cluster_health['status'] == 'red'
 | 
			
		||||
      Admin::SystemCheck::Message.new(:elasticsearch_health_red)
 | 
			
		||||
    elsif cluster_health['number_of_nodes'] < 2 && es_preset != 'single_node_cluster'
 | 
			
		||||
@@ -111,10 +116,20 @@ class Admin::SystemCheck::ElasticsearchCheck < Admin::SystemCheck::BaseCheck
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def mismatched_specifications_indexes
 | 
			
		||||
    @mismatched_specifications_indexes ||= INDEXES.filter_map do |klass|
 | 
			
		||||
      klass.base_name if klass.specification.changed?
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def indexes_match?
 | 
			
		||||
    mismatched_indexes.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def specifications_match?
 | 
			
		||||
    mismatched_specifications_indexes.empty?
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def es_preset
 | 
			
		||||
    ENV.fetch('ES_PRESET', 'single_node_cluster')
 | 
			
		||||
  end
 | 
			
		||||
 
 | 
			
		||||
@@ -903,6 +903,8 @@ en:
 | 
			
		||||
    system_checks:
 | 
			
		||||
      database_schema_check:
 | 
			
		||||
        message_html: There are pending database migrations. Please run them to ensure the application behaves as expected
 | 
			
		||||
      elasticsearch_analysis_index_mismatch:
 | 
			
		||||
        message_html: Elasticsearch index analyzer settings are outdated. Please run <code>tootctl search deploy --only-mapping --only=%{value}</code>
 | 
			
		||||
      elasticsearch_health_red:
 | 
			
		||||
        message_html: Elasticsearch cluster is unhealthy (red status), search features are unavailable
 | 
			
		||||
      elasticsearch_health_yellow:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user