Commit a322913c authored by Sean McGivern's avatar Sean McGivern

Merge branch 'ak/rescue-error' into 'master'

Rescue elasticsearch server error in pod logs

See merge request gitlab-org/gitlab!25367
parents 21d29a40 e3577373
---
title: Rescue elasticsearch server error in pod logs
merge_request: 25367
author:
type: fixed
......@@ -51,6 +51,14 @@ module PodLogs
)
success(result)
rescue Elasticsearch::Transport::Transport::ServerError => e
::Gitlab::ErrorTracking.track_exception(e)
error(_('Elasticsearch returned status code: %{status_code}') % {
# ServerError is the parent class of exceptions named after HTTP status codes, eg: "Elasticsearch::Transport::Transport::Errors::NotFound"
# there is no method on the exception other than the class name to determine the type of error encountered.
status_code: e.class.name.split('::').last
})
end
end
end
......@@ -157,5 +157,19 @@ describe ::PodLogs::ElasticsearchService do
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq('Unable to connect to Elasticsearch')
end
it 'handles server errors from elasticsearch' do
allow_any_instance_of(::Clusters::Applications::ElasticStack)
.to receive(:elasticsearch_client)
.and_return(Elasticsearch::Transport::Client.new)
allow_any_instance_of(::Gitlab::Elasticsearch::Logs)
.to receive(:pod_logs)
.and_raise(Elasticsearch::Transport::Transport::Errors::ServiceUnavailable.new)
result = subject.send(:pod_logs, result_arg)
expect(result[:status]).to eq(:error)
expect(result[:message]).to eq('Elasticsearch returned status code: ServiceUnavailable')
end
end
end
......@@ -7044,6 +7044,9 @@ msgstr ""
msgid "Elasticsearch integration. Elasticsearch AWS IAM."
msgstr ""
msgid "Elasticsearch returned status code: %{status_code}"
msgstr ""
msgid "Elastic|None. Select namespaces to index."
msgstr ""
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment