-
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.
[Saved Objects] Compatible mappings PR check (#148656)
## Summary This PR adds a technical control to prevent incompatible mappings changes. These include: 1. Removing mapped fields. For the foreseeable future we require that teams only introduce new fields - in short: this avoids the "reindex" step in our migrations. 2. Changing the type of a field. We leverage ES to determine whether a given set of mappings can be applied "on top" of another. Similarly, this avoids the "reindex" step in migrations. The above checks depend on a snapshot of the mappings from `main`, these are the "current" mappings and are extracted from plugin code. This PR will bootstrap `main` with an initial set of mappings extracted from plugins (bulk of new lines added). ## The new CLI See the added `README.md` for details on how the CLI works. ## How will it work? Any new PR that introduces compatible mappings changes will result in a new snapshot being captured, then merged to main for other PRs to merge and run the same checks against (currently committing new snapshots happens in the CI check so there is no manual step of maintaining the snapshot). ## Additional We should consider combining this CI check with the existing check in `src/core/server/integration_tests/saved_objects/migrations/check_registered_types.test.ts`. Hopefully we can automate the check such that no manual review is needed from Core, not sure how we might cover the hash of the non-mappings related fields. We could consider narrowing the Jest test to exclude mappings. ### Checklist - [x] [Unit or functional tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html) were updated or added to match the most common scenarios --------- Co-authored-by: kibanamachine <[email protected]> Co-authored-by: spalger <[email protected]>
- Loading branch information
1 parent
a0cd724
commit e9197ad
Showing
27 changed files
with
3,598 additions
and
4 deletions.
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
14 changes: 14 additions & 0 deletions
14
.buildkite/scripts/steps/checks/saved_objects_compat_changes.sh
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,14 @@ | ||
#!/usr/bin/env bash | ||
|
||
set -euo pipefail | ||
|
||
source .buildkite/scripts/common/util.sh | ||
|
||
echo --- Check Mappings Update | ||
cmd="node scripts/check_mappings_update" | ||
if is_pr && ! is_auto_commit_disabled; then | ||
cmd="$cmd --fix" | ||
fi | ||
|
||
eval "$cmd" | ||
check_for_changed_files "$cmd" true |
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
20 changes: 20 additions & 0 deletions
20
packages/core/plugins/core-plugins-server-internal/src/constants.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,20 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
/** | ||
* @internal | ||
*/ | ||
export const ENABLE_ALL_PLUGINS_CONFIG_PATH = 'forceEnableAllPlugins' as const; | ||
|
||
/** | ||
* Set this to true in the raw configuration passed to {@link Root} to force | ||
* enable all plugins. | ||
* @internal | ||
*/ | ||
export const PLUGIN_SYSTEM_ENABLE_ALL_PLUGINS_CONFIG_PATH = | ||
`plugins.${ENABLE_ALL_PLUGINS_CONFIG_PATH}` as const; |
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
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,7 @@ | ||
# @kbn/check-mappings-update-cli | ||
|
||
Saved Objects CLI tool that can be used to check whether a snapshot of current | ||
mappings (i.e., mappings on main) is compatible with mappings we can extract | ||
from the current code. | ||
|
||
See `node scripts/check_mappings_update --help` for more info. |
Oops, something went wrong.