From c6f33ce4525979b1b8a0cbc1f2e84e2c427244fd Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Mon, 14 Oct 2024 09:44:22 -0700 Subject: [PATCH] fallback if get remote info fails to cluster health call (#886) Signed-off-by: Amit Galitzky --- server/routes/opensearch.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/server/routes/opensearch.ts b/server/routes/opensearch.ts index 65f1e3a7..2ef9d8a9 100644 --- a/server/routes/opensearch.ts +++ b/server/routes/opensearch.ts @@ -570,14 +570,19 @@ export default class OpenSearchService { let clustersResponse: ClusterInfo[] = []; - const remoteInfo = await callWithRequest('transport.request', { - method: 'GET', - path: '/_remote/info', - }); - clustersResponse = Object.keys(remoteInfo).map((key) => ({ - name: key, - localCluster: false, - })); + try { + const remoteInfo = await callWithRequest('transport.request', { + method: 'GET', + path: '/_remote/info', + }); + clustersResponse = Object.keys(remoteInfo).map((key) => ({ + name: key, + localCluster: false, + })); + } catch (remoteErr) { + console.warn('Failed to fetch remote cluster info, proceeding with local datasource info only.', remoteErr); + } + const clusterHealth = await callWithRequest('cat.health', { format: 'json',