diff --git a/frontend/src/lib/k8s/api/v1/apiProxy.test.ts b/frontend/src/lib/k8s/api/v1/apiProxy.test.ts index 6fcca64fdf1..174b226a0a7 100644 --- a/frontend/src/lib/k8s/api/v1/apiProxy.test.ts +++ b/frontend/src/lib/k8s/api/v1/apiProxy.test.ts @@ -857,10 +857,8 @@ describe('apiProxy', () => { nock.cleanAll(); }); - it('Successfully checks cluster health', async () => { - const response = await apiProxy.testClusterHealth(clusterName); - const body = await response.text(); - expect(body).toEqual('ok'); + it('Should not raise an error on success', async () => { + await apiProxy.testClusterHealth(clusterName); }); it.each([ diff --git a/frontend/src/lib/k8s/api/v1/clusterApi.ts b/frontend/src/lib/k8s/api/v1/clusterApi.ts index dc0dc6c8f75..374a2d59bd3 100644 --- a/frontend/src/lib/k8s/api/v1/clusterApi.ts +++ b/frontend/src/lib/k8s/api/v1/clusterApi.ts @@ -6,7 +6,7 @@ import { findKubeconfigByClusterName, storeStatelessClusterKubeconfig, } from '../../../../stateless'; -import { getCluster } from '../../../util'; +import { getCluster, getClusterGroup } from '../../../util'; import { ClusterRequest, clusterRequest, post, request } from './clusterRequests'; import { JSON_HEADERS } from './constants'; @@ -29,8 +29,15 @@ export async function testAuth(cluster = '', namespace = 'default') { * Will throw an error if the cluster is not healthy. */ export async function testClusterHealth(cluster?: string) { - const clusterName = cluster || getCluster() || ''; - return clusterRequest('/healthz', { isJSON: false, cluster: clusterName }); + const clusterNames = cluster ? [cluster] : getClusterGroup(); + + const healthChecks = clusterNames.map(clusterName => { + return clusterRequest('/healthz', { isJSON: false, cluster: clusterName }).catch(error => { + throw new Error(`Cluster ${clusterName} is not healthy: ${error.message}`); + }); + }); + + return Promise.all(healthChecks); } export async function setCluster(clusterReq: ClusterRequest) {