Update code to throw a more user-friendly exception if index creation
failure so it's easier to track what is going on.
import copy
import importlib
+import traceback
import ssl as ssl_lib
import six
@@ -114,7 +115,15 @@ def db_ensure_indexes():
# Note: We need to ensure / create new indexes before removing extra ones
LOG.debug('Ensuring indexes for model "%s"...' % (model_class.__name__))
+
+ try:
model_class.ensure_indexes()
+ except Exception as e:
+ tb_msg = traceback.format_exc()
+ msg = 'Failed to ensure indexes for model "%s": %s' % (class_name, str(e))
+ msg += '\n\n' + tb_msg
+ exc_cls = type(e)
+ raise exc_cls(msg)
if model_class.__name__ in INDEX_CLEANUP_MODEL_NAMES_BLACKLIST:
LOG.debug('Skipping index cleanup for blacklisted model "%s"...' % (class_name))
