-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SO migration] remove v1 implementation (#118000)
* remove v1 implementation * fix type * remove unused mock * expose kibanaVersion again * fix migrator mock * move KibanaMigrator out of the kibana subfolder * fix imports * moves migrationsv2 into migrations * fix test mocking
- Loading branch information
1 parent
7ab3593
commit f716387
Showing
147 changed files
with
717 additions
and
3,994 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
40 changes: 0 additions & 40 deletions
40
src/core/server/saved_objects/migrations/core/__snapshots__/elastic_index.test.ts.snap
This file was deleted.
Oops, something went wrong.
28 changes: 0 additions & 28 deletions
28
src/core/server/saved_objects/migrations/core/call_cluster.ts
This file was deleted.
Oops, something went wrong.
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
60 changes: 60 additions & 0 deletions
60
src/core/server/saved_objects/migrations/core/disable_unknown_type_mapping_fields.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,60 @@ | ||
/* | ||
* 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 and the Server Side Public License, v 1; you may not use this file except | ||
* in compliance with, at your election, the Elastic License 2.0 or the Server | ||
* Side Public License, v 1. | ||
*/ | ||
|
||
import { SavedObjectsMappingProperties, IndexMapping } from '../../mappings'; | ||
|
||
/** | ||
* Merges the active mappings and the source mappings while disabling the | ||
* fields of any unknown Saved Object types present in the source index's | ||
* mappings. | ||
* | ||
* Since the Saved Objects index has `dynamic: strict` defined at the | ||
* top-level, only Saved Object types for which a mapping exists can be | ||
* inserted into the index. To ensure that we can continue to store Saved | ||
* Object documents belonging to a disabled plugin we define a mapping for all | ||
* the unknown Saved Object types that were present in the source index's | ||
* mappings. To limit the field count as much as possible, these unkwnown | ||
* type's mappings are set to `dynamic: false`. | ||
* | ||
* (Since we're using the source index mappings instead of looking at actual | ||
* document types in the inedx, we potentially add more "unknown types" than | ||
* what would be necessary to support migrating all the data over to the | ||
* target index.) | ||
* | ||
* @param activeMappings The mappings compiled from all the Saved Object types | ||
* known to this Kibana node. | ||
* @param sourceMappings The mappings of index used as the migration source. | ||
* @returns The mappings that should be applied to the target index. | ||
*/ | ||
export function disableUnknownTypeMappingFields( | ||
activeMappings: IndexMapping, | ||
sourceMappings: IndexMapping | ||
): IndexMapping { | ||
const targetTypes = Object.keys(activeMappings.properties); | ||
|
||
const disabledTypesProperties = Object.keys(sourceMappings.properties ?? {}) | ||
.filter((sourceType) => { | ||
const isObjectType = 'properties' in sourceMappings.properties[sourceType]; | ||
// Only Object/Nested datatypes can be excluded from the field count by | ||
// using `dynamic: false`. | ||
return !targetTypes.includes(sourceType) && isObjectType; | ||
}) | ||
.reduce((disabledTypesAcc, sourceType) => { | ||
disabledTypesAcc[sourceType] = { dynamic: false, properties: {} }; | ||
return disabledTypesAcc; | ||
}, {} as SavedObjectsMappingProperties); | ||
|
||
return { | ||
...activeMappings, | ||
properties: { | ||
...sourceMappings.properties, | ||
...disabledTypesProperties, | ||
...activeMappings.properties, | ||
}, | ||
}; | ||
} |
Oops, something went wrong.