-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds error from es call to nodes.info to the nodes version compatibility response message #100005
Merged
TinaHeiligers
merged 11 commits into
elastic:master
from
TinaHeiligers:add-response-erros-to-nodes-version-compatibility
May 14, 2021
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
f0904ff
Adds error from es call to nodes.info to the nodes version compatibil…
TinaHeiligers ed29908
Adds jest unit tests to check response handling for errors returned f…
TinaHeiligers 4e9abe8
Cleans up comments
TinaHeiligers a432b99
Merge branch 'master' into log-es-errors-on-nodes-info-call
TinaHeiligers a40c110
Simplifies request error message checking
TinaHeiligers afd661c
Adds nodes info request error change test to status, renames error pr…
TinaHeiligers c6f3fee
Updates API docs
TinaHeiligers b8601c3
Merge branch 'master' into add-response-erros-to-nodes-version-compat…
kibanamachine 81147e9
Improves unit test error creation
TinaHeiligers d389eac
iMerge branch 'master' into add-response-erros-to-nodes-version-compa…
TinaHeiligers 4985477
Addresses PR changes
TinaHeiligers File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...rver/kibana-plugin-core-server.elasticsearchstatusmeta.nodesinforequesterror.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [ElasticsearchStatusMeta](./kibana-plugin-core-server.elasticsearchstatusmeta.md) > [nodesInfoRequestError](./kibana-plugin-core-server.elasticsearchstatusmeta.nodesinforequesterror.md) | ||
|
||
## ElasticsearchStatusMeta.nodesInfoRequestError property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
nodesInfoRequestError?: NodesVersionCompatibility['nodesInfoRequestError']; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
...er/kibana-plugin-core-server.nodesversioncompatibility.nodesinforequesterror.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [kibana-plugin-core-server](./kibana-plugin-core-server.md) > [NodesVersionCompatibility](./kibana-plugin-core-server.nodesversioncompatibility.md) > [nodesInfoRequestError](./kibana-plugin-core-server.nodesversioncompatibility.nodesinforequesterror.md) | ||
|
||
## NodesVersionCompatibility.nodesInfoRequestError property | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
nodesInfoRequestError?: Error; | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,8 @@ const mockLogger = mockLoggerFactory.get('mock logger'); | |
const KIBANA_VERSION = '5.1.0'; | ||
|
||
const createEsSuccess = elasticsearchClientMock.createSuccessTransportRequestPromise; | ||
const createEsError = elasticsearchClientMock.createErrorTransportRequestPromise; | ||
const createEsErrorReturn = (err: any) => | ||
elasticsearchClientMock.createErrorTransportRequestPromise(err); | ||
|
||
function createNodes(...versions: string[]): NodesInfo { | ||
const nodes = {} as any; | ||
|
@@ -102,6 +103,28 @@ describe('mapNodesVersionCompatibility', () => { | |
`"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.1.1 @ http_address (ip)"` | ||
); | ||
}); | ||
|
||
it('returns isCompatible=false without an extended message when a nodesInfoRequestError is not provided', async () => { | ||
const result = mapNodesVersionCompatibility({ nodes: {} }, KIBANA_VERSION, false); | ||
expect(result.isCompatible).toBe(false); | ||
expect(result.nodesInfoRequestError).toBeUndefined(); | ||
expect(result.message).toMatchInlineSnapshot( | ||
`"Unable to retrieve version information from Elasticsearch nodes."` | ||
); | ||
}); | ||
|
||
it('returns isCompatible=false with an extended message when a nodesInfoRequestError is present', async () => { | ||
const result = mapNodesVersionCompatibility( | ||
{ nodes: {}, nodesInfoRequestError: new Error('connection refused') }, | ||
KIBANA_VERSION, | ||
false | ||
); | ||
expect(result.isCompatible).toBe(false); | ||
expect(result.nodesInfoRequestError).toBeTruthy(); | ||
expect(result.message).toMatchInlineSnapshot( | ||
`"Unable to retrieve version information from Elasticsearch nodes. connection refused"` | ||
); | ||
}); | ||
}); | ||
|
||
describe('pollEsNodesVersion', () => { | ||
|
@@ -119,10 +142,10 @@ describe('pollEsNodesVersion', () => { | |
internalClient.nodes.info.mockImplementationOnce(() => createEsSuccess(infos)); | ||
}; | ||
const nodeInfosErrorOnce = (error: any) => { | ||
internalClient.nodes.info.mockImplementationOnce(() => createEsError(error)); | ||
internalClient.nodes.info.mockImplementationOnce(() => createEsErrorReturn(new Error(error))); | ||
}; | ||
|
||
it('returns iscCompatible=false and keeps polling when a poll request throws', (done) => { | ||
it('returns isCompatible=false and keeps polling when a poll request throws', (done) => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Cleans up a typo |
||
expect.assertions(3); | ||
const expectedCompatibilityResults = [false, false, true]; | ||
jest.clearAllMocks(); | ||
|
@@ -148,6 +171,100 @@ describe('pollEsNodesVersion', () => { | |
}); | ||
}); | ||
|
||
it('returns the error from a failed nodes.info call when a poll request throws', (done) => { | ||
expect.assertions(2); | ||
const expectedCompatibilityResults = [false]; | ||
const expectedMessageResults = [ | ||
'Unable to retrieve version information from Elasticsearch nodes. mock request error', | ||
]; | ||
jest.clearAllMocks(); | ||
|
||
nodeInfosErrorOnce('mock request error'); | ||
|
||
pollEsNodesVersion({ | ||
internalClient, | ||
esVersionCheckInterval: 1, | ||
ignoreVersionMismatch: false, | ||
kibanaVersion: KIBANA_VERSION, | ||
log: mockLogger, | ||
}) | ||
.pipe(take(1)) | ||
.subscribe({ | ||
next: (result) => { | ||
expect(result.isCompatible).toBe(expectedCompatibilityResults.shift()); | ||
expect(result.message).toBe(expectedMessageResults.shift()); | ||
}, | ||
complete: done, | ||
error: done, | ||
}); | ||
}); | ||
|
||
it('only emits if the error from a failed nodes.info call changed from the previous poll', (done) => { | ||
expect.assertions(4); | ||
const expectedCompatibilityResults = [false, false]; | ||
const expectedMessageResults = [ | ||
'Unable to retrieve version information from Elasticsearch nodes. mock request error', | ||
'Unable to retrieve version information from Elasticsearch nodes. mock request error 2', | ||
]; | ||
jest.clearAllMocks(); | ||
|
||
nodeInfosErrorOnce('mock request error'); // emit | ||
nodeInfosErrorOnce('mock request error'); // ignore, same error message | ||
nodeInfosErrorOnce('mock request error 2'); // emit | ||
|
||
pollEsNodesVersion({ | ||
internalClient, | ||
esVersionCheckInterval: 1, | ||
ignoreVersionMismatch: false, | ||
kibanaVersion: KIBANA_VERSION, | ||
log: mockLogger, | ||
}) | ||
.pipe(take(2)) | ||
.subscribe({ | ||
next: (result) => { | ||
expect(result.message).toBe(expectedMessageResults.shift()); | ||
expect(result.isCompatible).toBe(expectedCompatibilityResults.shift()); | ||
}, | ||
complete: done, | ||
error: done, | ||
}); | ||
}); | ||
|
||
it('returns isCompatible=false and keeps polling when a poll request throws, only responding again if the error message has changed', (done) => { | ||
expect.assertions(8); | ||
const expectedCompatibilityResults = [false, false, true, false]; | ||
const expectedMessageResults = [ | ||
'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', | ||
]; | ||
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'); // emit | ||
|
||
pollEsNodesVersion({ | ||
internalClient, | ||
esVersionCheckInterval: 1, | ||
ignoreVersionMismatch: false, | ||
kibanaVersion: KIBANA_VERSION, | ||
log: mockLogger, | ||
}) | ||
.pipe(take(4)) | ||
.subscribe({ | ||
next: (result) => { | ||
expect(result.isCompatible).toBe(expectedCompatibilityResults.shift()); | ||
expect(result.message).toBe(expectedMessageResults.shift()); | ||
}, | ||
complete: done, | ||
error: done, | ||
}); | ||
}); | ||
|
||
it('returns compatibility results', (done) => { | ||
expect.assertions(1); | ||
const nodes = createNodes('5.1.0', '5.2.0', '5.0.0'); | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cleans up a typo