forked from elastic/kibana
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Upgrade Assistant] Hide system indices from es deprecations list (el…
- Loading branch information
1 parent
62b66ee
commit 15cd95d
Showing
6 changed files
with
172 additions
and
1 deletion.
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; | ||
}; |