-
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
[SO migration] remove v1 implementation #118000
Merged
pgayvallet
merged 12 commits into
elastic:main
from
pgayvallet:kbn-96396-remove-so-mig-v1-reloaded
Nov 10, 2021
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
9e783ea
remove v1 implementation
pgayvallet 920d2f2
fix type
pgayvallet 480890a
remove unused mock
pgayvallet a1f30e9
expose kibanaVersion again
pgayvallet 8451824
Merge remote-tracking branch 'upstream/main' into kbn-96396-remove-so…
pgayvallet 50945c2
fix migrator mock
pgayvallet 32446ab
Merge remote-tracking branch 'upstream/main' into kbn-96396-remove-so…
pgayvallet 6445b20
Merge remote-tracking branch 'upstream/main' into kbn-96396-remove-so…
pgayvallet 115e51c
move KibanaMigrator out of the kibana subfolder
pgayvallet 50a9ed1
fix imports
pgayvallet 92655c4
moves migrationsv2 into migrations
pgayvallet 1c8d78a
fix test mocking
pgayvallet 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
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.
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.
Extracted from
migration_context.ts
, as this was the only function that is still used by v2.