Test ES connection only for the default user (#1028)

This commit is contained in:
oryx1729 2021-05-04 15:03:19 +02:00 committed by GitHub
parent c41101ff74
commit 9bec8859f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -182,9 +182,15 @@ class ElasticsearchDocumentStore(BaseDocumentStore):
# Test connection
try:
# ping uses a HEAD request on the root URI. In some cases, the user might not have permissions for that,
# resulting in a HTTP Forbidden 403 response.
if username in ["", "elastic"]:
status = client.ping()
if not status:
raise ConnectionError(f"Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at `{hosts}` and that it has finished the initial ramp up (can take > 30s).")
raise ConnectionError(
f"Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance "
f"at `{hosts}` and that it has finished the initial ramp up (can take > 30s)."
)
except Exception:
raise ConnectionError(
f"Initial connection to Elasticsearch failed. Make sure you run an Elasticsearch instance at `{hosts}` and that it has finished the initial ramp up (can take > 30s).")