From 49854776af4bb15c746e5a8223e91d2e53820635 Mon Sep 17 00:00:00 2001 From: Christiane Heiligers Date: Fri, 14 May 2021 08:40:45 -0700 Subject: [PATCH] Addresses PR changes --- src/core/server/elasticsearch/status.ts | 16 +++++----------- .../version_check/ensure_es_version.test.ts | 4 ++-- .../version_check/ensure_es_version.ts | 7 +++---- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/src/core/server/elasticsearch/status.ts b/src/core/server/elasticsearch/status.ts index 6f579ba4edf82..23e44b71863f1 100644 --- a/src/core/server/elasticsearch/status.ts +++ b/src/core/server/elasticsearch/status.ts @@ -35,23 +35,17 @@ export const calculateStatus$ = ( nodesInfoRequestError, }): ServiceStatus => { if (!isCompatible) { - if (!nodesInfoRequestError) { - return { - level: ServiceStatusLevels.critical, - summary: - // Message should always be present, but this is a safe fallback - message ?? - `Some Elasticsearch nodes are not compatible with this version of Kibana`, - meta: { warningNodes, incompatibleNodes }, - }; - } return { level: ServiceStatusLevels.critical, summary: // Message should always be present, but this is a safe fallback message ?? `Some Elasticsearch nodes are not compatible with this version of Kibana`, - meta: { warningNodes, incompatibleNodes, nodesInfoRequestError }, + meta: { + warningNodes, + incompatibleNodes, + ...(nodesInfoRequestError && { nodesInfoRequestError }), + }, }; } else if (warningNodes.length > 0) { return { diff --git a/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts b/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts index 9d571e93d4195..70166704679fe 100644 --- a/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts +++ b/src/core/server/elasticsearch/version_check/ensure_es_version.test.ts @@ -237,7 +237,7 @@ describe('pollEsNodesVersion', () => { 'This version of Kibana (v5.1.0) is incompatible with the following Elasticsearch nodes in your cluster: v5.0.0 @ http_address (ip)', 'Unable to retrieve version information from Elasticsearch nodes. mock request error', "You're running Kibana 5.1.0 with some different versions of Elasticsearch. Update Kibana or Elasticsearch to the same version to prevent compatibility issues: v5.2.0 @ http_address (ip), v5.1.1-Beta1 @ http_address (ip)", - 'Unable to retrieve version information from Elasticsearch nodes. mock request error 2', + 'Unable to retrieve version information from Elasticsearch nodes. mock request error', ]; jest.clearAllMocks(); @@ -245,7 +245,7 @@ describe('pollEsNodesVersion', () => { nodeInfosErrorOnce('mock request error'); // emit nodeInfosErrorOnce('mock request error'); // ignore nodeInfosSuccessOnce(createNodes('5.1.0', '5.2.0', '5.1.1-Beta1')); // emit - nodeInfosErrorOnce('mock request error 2'); // emit + nodeInfosErrorOnce('mock request error'); // emit pollEsNodesVersion({ internalClient, diff --git a/src/core/server/elasticsearch/version_check/ensure_es_version.ts b/src/core/server/elasticsearch/version_check/ensure_es_version.ts index 55292082c47fe..43cd52f1b5721 100644 --- a/src/core/server/elasticsearch/version_check/ensure_es_version.ts +++ b/src/core/server/elasticsearch/version_check/ensure_es_version.ts @@ -74,7 +74,7 @@ export function mapNodesVersionCompatibility( incompatibleNodes: [], warningNodes: [], kibanaVersion, - nodesInfoRequestError: nodesInfoResponse.nodesInfoRequestError, // optionally stringify the whole Error or parts of it that we're interested in + nodesInfoRequestError: nodesInfoResponse.nodesInfoRequestError, }; } const nodes = Object.keys(nodesInfoResponse.nodes) @@ -129,7 +129,6 @@ function compareNodesInfoErrorMessages( // Returns true if two NodesVersionCompatibility entries match function compareNodes(prev: NodesVersionCompatibility, curr: NodesVersionCompatibility) { const nodesEqual = (n: NodeInfo, m: NodeInfo) => n.ip === m.ip && n.version === m.version; - // if we pass the full error back in here, we can check to see if it's the same error rather than checking return ( curr.isCompatible === prev.isCompatible && curr.incompatibleNodes.length === prev.incompatibleNodes.length && @@ -156,8 +155,8 @@ export const pollEsNodesVersion = ({ }) ).pipe( map(({ body }) => body), - catchError((_err) => { - return of({ nodes: {}, nodesInfoRequestError: _err }); + catchError((nodesInfoRequestError) => { + return of({ nodes: {}, nodesInfoRequestError }); }) ); }),