diff --git a/es.py b/es.py index 4688dc48b86cde4ee320c5ad741e8760fcc20846_ZXMucHk=..9aaca4248297b49131f1a5947b5cee879474e017_ZXMucHk= 100644 --- a/es.py +++ b/es.py @@ -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