# HG changeset patch # User Arthur Lutz <arthur.lutz@logilab.fr> # Date 1464961539 -7200 # Fri Jun 03 15:45:39 2016 +0200 # Node ID f69eb7eca7c06b9bbf027641857d60fddfc77623 # Parent b0c5492076443c6ac01fc8d3fd914354e53268f4 [hooks] try/except when attempting to create index diff --git a/hooks.py b/hooks.py --- a/hooks.py +++ b/hooks.py @@ -51,10 +51,13 @@ if locations and index_name: es = Elasticsearch(locations and locations.split(',')) # TODO : have a cache so that we don't check index on every transition - if not es.indices.exists(index=index_name): - es.indices.create(index=index_name, - body=INDEX_SETTINGS, - ignore=400) + try: + if not es.indices.exists(index=index_name): + es.indices.create(index=index_name, + body=INDEX_SETTINGS, + ignore=400) + except (ConnectionError, ProtocolError): + log.debug('Failed to index in hook, could not connect to ES') # serializer = self.entity.cw_adapt_to('IFTISerializable') serializer = self.entity.cw_adapt_to('ISerializable') json = serializer.serialize()