mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[SLM] Hide system indices in snapshot restore flow (#123365)
* Dedupe system indices from indices array * commit using @elastic.co Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
This commit is contained in:
parent
556d00d3a8
commit
ed5185283f
3 changed files with 44 additions and 8 deletions
|
@ -18,7 +18,7 @@ describe('Snapshot serialization and deserialization', () => {
|
|||
repository: 'repositoryName',
|
||||
version_id: 5,
|
||||
version: 'version',
|
||||
indices: ['index2', 'index3', 'index1'],
|
||||
indices: ['index2', 'index3', 'index1', '.kibana'],
|
||||
include_global_state: false,
|
||||
state: 'SUCCESS',
|
||||
start_time: '0',
|
||||
|
@ -31,6 +31,12 @@ describe('Snapshot serialization and deserialization', () => {
|
|||
failed: 1,
|
||||
successful: 2,
|
||||
},
|
||||
feature_states: [
|
||||
{
|
||||
feature_name: 'kibana',
|
||||
indices: ['.kibana'],
|
||||
},
|
||||
],
|
||||
failures: [
|
||||
{
|
||||
index: 'z',
|
||||
|
@ -71,6 +77,12 @@ describe('Snapshot serialization and deserialization', () => {
|
|||
failed: 1,
|
||||
successful: 2,
|
||||
},
|
||||
feature_states: [
|
||||
{
|
||||
feature_name: 'kibana',
|
||||
indices: ['.kibana'],
|
||||
},
|
||||
],
|
||||
failures: [
|
||||
{
|
||||
index: 'z',
|
||||
|
@ -98,7 +110,7 @@ describe('Snapshot serialization and deserialization', () => {
|
|||
uuid: 'UUID',
|
||||
versionId: 5,
|
||||
version: 'version',
|
||||
// Indices are sorted.
|
||||
// Indices are sorted and dont include any of the system indices listed in feature_state
|
||||
indices: ['index1', 'index2', 'index3'],
|
||||
dataStreams: [],
|
||||
includeGlobalState: false,
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
import { sortBy } from 'lodash';
|
||||
import { flow, map, flatten, uniq } from 'lodash/fp';
|
||||
|
||||
import {
|
||||
SnapshotDetails,
|
||||
|
@ -20,6 +21,19 @@ import { deserializeTime, serializeTime } from './time_serialization';
|
|||
|
||||
import { csvToArray } from './utils';
|
||||
|
||||
export const convertFeaturesToIndicesArray = (
|
||||
features: SnapshotDetailsEs['feature_states']
|
||||
): string[] => {
|
||||
return flow(
|
||||
// Map each feature into Indices[]
|
||||
map('indices'),
|
||||
// Flatten the array
|
||||
flatten,
|
||||
// And finally dedupe the indices
|
||||
uniq
|
||||
)(features);
|
||||
};
|
||||
|
||||
export function deserializeSnapshotDetails(
|
||||
snapshotDetailsEs: SnapshotDetailsEs,
|
||||
managedRepository?: string,
|
||||
|
@ -46,21 +60,27 @@ export function deserializeSnapshotDetails(
|
|||
duration_in_millis: durationInMillis,
|
||||
failures = [],
|
||||
shards,
|
||||
feature_states: featureStates = [],
|
||||
metadata: { policy: policyName } = { policy: undefined },
|
||||
} = snapshotDetailsEs;
|
||||
|
||||
const systemIndices = convertFeaturesToIndicesArray(featureStates);
|
||||
const snapshotIndicesWithoutSystemIndices = indices
|
||||
.filter((index) => !systemIndices.includes(index))
|
||||
.sort();
|
||||
|
||||
// If an index has multiple failures, we'll want to see them grouped together.
|
||||
const indexToFailuresMap = failures.reduce((map, failure) => {
|
||||
const indexToFailuresMap = failures.reduce((aggregation, failure) => {
|
||||
const { index, ...rest } = failure;
|
||||
if (!map[index]) {
|
||||
map[index] = {
|
||||
if (!aggregation[index]) {
|
||||
aggregation[index] = {
|
||||
index,
|
||||
failures: [],
|
||||
};
|
||||
}
|
||||
|
||||
map[index].failures.push(rest);
|
||||
return map;
|
||||
aggregation[index].failures.push(rest);
|
||||
return aggregation;
|
||||
}, {});
|
||||
|
||||
// Sort all failures by their shard.
|
||||
|
@ -80,7 +100,7 @@ export function deserializeSnapshotDetails(
|
|||
uuid,
|
||||
versionId,
|
||||
version,
|
||||
indices: [...indices].sort(),
|
||||
indices: snapshotIndicesWithoutSystemIndices,
|
||||
dataStreams: [...dataStreams].sort(),
|
||||
includeGlobalState,
|
||||
state,
|
||||
|
|
|
@ -68,6 +68,10 @@ export interface SnapshotDetailsEs {
|
|||
duration_in_millis: number;
|
||||
failures: any[];
|
||||
shards: SnapshotDetailsShardsStatusEs;
|
||||
feature_states: Array<{
|
||||
feature_name: string;
|
||||
indices: string[];
|
||||
}>;
|
||||
metadata?: {
|
||||
policy: string;
|
||||
[key: string]: any;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue