Skip to content
Snippets Groups Projects
Commit 9aaca4248297 authored by Arthur Lutz's avatar Arthur Lutz
Browse files

[es] extra safetly belt for index creation

parent 4688dc48b86c
No related branches found
No related tags found
No related merge requests found
......@@ -17,7 +17,7 @@
import logging
from elasticsearch.exceptions import ConnectionError
from elasticsearch.exceptions import ConnectionError, TransportError
from urllib3.exceptions import ProtocolError
from elasticsearch_dsl.connections import connections
......@@ -106,8 +106,11 @@
timeout=20)
try:
if not es.indices.exists(index=index_name):
es.indices.create(index=index_name,
body=settings)
try:
es.indices.create(index=index_name,
body=settings)
except TransportError:
log.error('Failed to create index {}'.format(index_name))
except (ConnectionError, ProtocolError):
log.debug('Failed to index in hook, could not connect to ES')
return es
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment