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

[hooks] try/except when attempting to create index

parent b0c549207644
No related branches found
No related tags found
No related merge requests found
......@@ -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()
......
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