Skip to content

Commit

Permalink
Addresses PR changes
Browse files Browse the repository at this point in the history
  • Loading branch information
TinaHeiligers committed May 14, 2021
1 parent d389eac commit 4985477
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 17 deletions.
16 changes: 5 additions & 11 deletions src/core/server/elasticsearch/status.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,23 +35,17 @@ export const calculateStatus$ = (
nodesInfoRequestError,
}): ServiceStatus<ElasticsearchStatusMeta> => {
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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,15 +237,15 @@ 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();

nodeInfosSuccessOnce(createNodes('5.1.0', '5.2.0', '5.0.0')); // emit
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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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 &&
Expand All @@ -156,8 +155,8 @@ export const pollEsNodesVersion = ({
})
).pipe(
map(({ body }) => body),
catchError((_err) => {
return of({ nodes: {}, nodesInfoRequestError: _err });
catchError((nodesInfoRequestError) => {
return of({ nodes: {}, nodesInfoRequestError });
})
);
}),
Expand Down

0 comments on commit 4985477

Please sign in to comment.