def update_template(es, max_retry, template_path, template_name):
with open(template_path) as f:
body = f.read()
for i in range(max_retry, 0, -1):
try:
es.indices.put_template(name=template_name, body=body)
log.info("Updating template {!r} done".format(template_name))
return
except (ConnectionError, NotFoundError):
log.warning(
"Updating template {!r} failed. Waiting for {} sec".format(
template_name, i))
time.sleep(i)
log.error("Updating template {!r} definitely failed".format(template_name))
评论列表
文章目录