-
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
[Upgrade Assistant] Hide system indices from es deprecations list #113627
Merged
sabarasaba
merged 10 commits into
elastic:7.x
from
sabarasaba:ua/hide_system_indices_es_deprecations_table
Oct 5, 2021
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6a5cc6c
Fetch system indices upgrade, generate a uniq list of them and use it…
sabarasaba d97ec02
Fix broken tests and add more
sabarasaba 5cca444
Remove testing mock
sabarasaba 357d6b2
Add tests for convertFeaturesListToArray
sabarasaba 5520ed5
Add comments for why we filter out system indices
sabarasaba fc5a591
Rename function that converts features to index array
sabarasaba fa4aa28
Rename function to convertFeaturesToIndicesArray
sabarasaba a0389f2
Refactor var name
sabarasaba 9b025dd
Refactor api call
sabarasaba be5996e
Merge branch '7.x' into ua/hide_system_indices_es_deprecations_table
kibanamachine 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
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
52 changes: 52 additions & 0 deletions
52
x-pack/plugins/upgrade_assistant/server/lib/es_system_indices_upgrade.test.ts
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,52 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { convertFeaturesToIndicesArray } from './es_system_indices_upgrade'; | ||
import { SystemIndicesUpgradeStatus } from '../../common/types'; | ||
|
||
const esUpgradeSystemIndicesStatusMock: SystemIndicesUpgradeStatus = { | ||
features: [ | ||
{ | ||
feature_name: 'machine_learning', | ||
minimum_index_version: '7.1.1', | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
indices: [ | ||
{ | ||
index: '.ml-config', | ||
version: '7.1.1', | ||
}, | ||
{ | ||
index: '.ml-notifications', | ||
version: '7.1.1', | ||
}, | ||
], | ||
}, | ||
{ | ||
feature_name: 'security', | ||
minimum_index_version: '7.1.1', | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
indices: [ | ||
{ | ||
index: '.ml-config', | ||
version: '7.1.1', | ||
}, | ||
], | ||
}, | ||
], | ||
upgrade_status: 'UPGRADE_NEEDED', | ||
}; | ||
|
||
describe('convertFeaturesToIndicesArray', () => { | ||
it('converts list with features to flat array of uniq indices', async () => { | ||
const result = convertFeaturesToIndicesArray(esUpgradeSystemIndicesStatusMock.features); | ||
expect(result).toEqual(['.ml-config', '.ml-notifications']); | ||
}); | ||
|
||
it('returns empty array if no features are passed to it', async () => { | ||
expect(convertFeaturesToIndicesArray([])).toEqual([]); | ||
}); | ||
}); |
36 changes: 36 additions & 0 deletions
36
x-pack/plugins/upgrade_assistant/server/lib/es_system_indices_upgrade.ts
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,36 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { flow, flatMap, map, flatten, uniq } from 'lodash/fp'; | ||
import { ElasticsearchClient } from 'src/core/server'; | ||
import { SystemIndicesUpgradeStatus, SystemIndicesUpgradeFeature } from '../../common/types'; | ||
|
||
export const convertFeaturesToIndicesArray = ( | ||
features: SystemIndicesUpgradeFeature[] | ||
): string[] => { | ||
return flow( | ||
// Map each feature into Indices[] | ||
map('indices'), | ||
// Flatten each into an string[] of indices | ||
map(flatMap('index')), | ||
// Flatten the array | ||
flatten, | ||
// And finally dedupe the indices | ||
uniq | ||
)(features); | ||
}; | ||
|
||
export const getESSystemIndicesUpgradeStatus = async ( | ||
client: ElasticsearchClient | ||
): Promise<SystemIndicesUpgradeStatus> => { | ||
const { body } = await client.transport.request({ | ||
method: 'GET', | ||
path: '/_migration/system_features', | ||
}); | ||
|
||
return body as SystemIndicesUpgradeStatus; | ||
}; |
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.
I've created an issue elastic/elasticsearch-js#1561 for the elasticsearch-js team to add the missing function
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.
In the docs page there's an unresolved todo item to verify something about a possibly required permission. I've asked the ES team for clarification on that and if required we can add a check for it in a subsequent PR.