From 08630a67f4e1b05fdb75dde3d946212e33855539 Mon Sep 17 00:00:00 2001 From: Amit Galitzky Date: Fri, 11 Oct 2024 08:38:40 -0700 Subject: [PATCH] fallback if get remote info fails to cluster health call 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',