Improve error messages in ES administration
Summary
This is a follow-up to !17230 (closed) / !18254 (merged) / !20421 (merged).
Currently the ES administration only implements some basic error handling for ES connection failures when creating/deleting indices, and shows them as a general validation error rather than next to the form fields with the faulty value(s).
Some information about the error data we get from ES and other involved gems:
- The ES gem gives us exceptions based on the different HTTP statuses, e.g. types like
Elasticsearch::Transport::Transport::Errors::NotFoundfor a 404: https://github.com/elastic/elasticsearch-ruby/blob/v5.0.3/elasticsearch-transport/lib/elasticsearch/transport/transport/errors.rb#L19-L63 - The ES exception messages look like this:
[404] {"error":{"root_cause":[{"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"gitlab-development-v12p1","index_uuid":"_na_","index":"gitlab-development-v12p1"}],"type":"index_not_found_exception","reason":"no such index","resource.type":"index_or_alias","resource.id":"gitlab-development-v12p1","index_uuid":"_na_","index":"gitlab-development-v12p1"},"status":404})- ES itself returns details in structured JSON, but the ES gem combines all of it into one string with the format
[$HTTP_STATUS] $JSON_BODY. This message could be parsed to identify more details.
- ES itself returns details in structured JSON, but the ES gem combines all of it into one string with the format
- Some general connection errors are returned by the Faraday gem (which is the HTTP client the ES gem uses), with e.g. a type like
Faraday::ConnectionFailedand a message like:(Connection refused - Connection refused - connect(2) for "localhost" port 9201 (localhost:9201))
Improvements
It's not clear yet which error cases could benefit most from more user-friendly error messages.
The main thing we noticed is that it would be helpful to identify which form fields are to blame for connection errors, so we could show a validation error next to the relevant urls or AWS fields.
Involved components
ee/app/assets/javascripts/elasticsearch/ee/app/services/elastic/create_index_service.rbee/app/services/elastic/destroy_index_service.rbee/lib/api/elasticsearch_indices.rb
Edited by Markus Koller