From 4f22813743e728547d99da63300a661890680b48 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Mon, 14 Oct 2024 14:21:10 -0700 Subject: [PATCH] fallback if get remote info fails to cluster health call (#886) (#896) 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',