# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1472227192 -7200 # Fri Aug 26 17:59:52 2016 +0200 # Node ID 9aaca4248297b49131f1a5947b5cee879474e017 # Parent 4688dc48b86cde4ee320c5ad741e8760fcc20846 [es] extra safetly belt for index creation diff --git a/es.py b/es.py --- 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