Skip to content

Commit

Permalink
Add ES_PRESET check to admin dashboard
Browse files Browse the repository at this point in the history
  • Loading branch information
ClearlyClaire committed Aug 18, 2023
1 parent 0834062 commit 0394e4e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
12 changes: 10 additions & 2 deletions app/lib/admin/system_check/elasticsearch_check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def skip?
def pass?
return true unless Chewy.enabled?

running_version.present? && compatible_version? && cluster_health['status'] == 'green' && indexes_match?
running_version.present? && compatible_version? && cluster_health['status'] == 'green' && indexes_match? && preset_matches?
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
false
end
Expand All @@ -39,8 +39,12 @@ def message
)
elsif cluster_health['status'] == 'red'
Admin::SystemCheck::Message.new(:elasticsearch_health_red)
else
elsif cluster_health['number_of_nodes'] < 2 && ENV.fetch('ES_PRESET', 'single_node_cluster') != 'single_node_cluster'
Admin::SystemCheck::Message.new(:elasticsearch_preset_single_node, nil, 'https://docs.joinmastodon.org/admin/optional/elasticsearch/#scaling')
elsif cluster_health['status'] == 'yellow'
Admin::SystemCheck::Message.new(:elasticsearch_health_yellow)
else
Admin::SystemCheck::Message.new(:elasticsearch_preset, nil, 'https://docs.joinmastodon.org/admin/optional/elasticsearch/#scaling')
end
rescue Faraday::ConnectionFailed, Elasticsearch::Transport::Transport::Error
Admin::SystemCheck::Message.new(:elasticsearch_running_check)
Expand Down Expand Up @@ -86,4 +90,8 @@ def mismatched_indexes
def indexes_match?
mismatched_indexes.empty?
end

def preset_matches?
(cluster_health['number_of_nodes'] < 2) == (ENV.fetch('ES_PRESET', 'single_node_cluster') == 'single_node_cluster')
end
end
6 changes: 6 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,12 @@ en:
message_html: Elasticsearch cluster is unhealthy (yellow status), you may want to review your setup
elasticsearch_index_mismatch:
message_html: Elasticsearch index mappings are outdated. Please run <code>tootctl search deploy --only=%{value}</code>
elasticsearch_preset:
action: See documentation
message_html: Your Elastic Search cluster has more than one node, but is only using one.
elasticsearch_preset_single_node:
action: See documentation
message_html: Your Elastic Search cluster has only one node, <code>ES_PRESET</code> should be set to <code>single_node_cluster</code>.
elasticsearch_running_check:
message_html: Could not connect to Elasticsearch. Please check that it is running, or disable full-text search
elasticsearch_version_check:
Expand Down

0 comments on commit 0394e4e

Please sign in to comment.