From e1030e29bbd192953ab742f593dd8da43a7af684 Mon Sep 17 00:00:00 2001 From: Bryan Newbold Date: Tue, 6 Apr 2021 15:56:22 -0700 Subject: change health check from .exists(index) to .mapping(index) In cases where the cluser leader node is unavilable, the health check was returning false even when the local node had full shard replicas and could return requests. A refinement of this change would be to use the //_count API endpoint to ensure that the "failed" and "skipped" shard numbers are 0 (aka, "successful == total"). However, not sure where that endpoint is exposed in the elasticsearch-py API. the CatClient method doesn't seem right. --- fatcat_scholar/web.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'fatcat_scholar/web.py') diff --git a/fatcat_scholar/web.py b/fatcat_scholar/web.py index 6cda5b7..895af18 100644 --- a/fatcat_scholar/web.py +++ b/fatcat_scholar/web.py @@ -25,7 +25,7 @@ from fatcat_scholar.search import ( process_query, FulltextQuery, FulltextHits, - es_scholar_index_exists, + es_scholar_index_alive, ) from fatcat_scholar.schema import ScholarDoc @@ -118,7 +118,7 @@ def health_get() -> Any: """ Checks that connection back to elasticsearch index is working. """ - if not es_scholar_index_exists(): + if not es_scholar_index_alive(): raise HTTPException(status_code=503) return Response() -- cgit v1.2.3