-
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
Use modelVersions instead of hashes to track changes in SO types #176803
Use modelVersions instead of hashes to track changes in SO types #176803
Conversation
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.
Overall approach makes sense to me to facilitate the transition away from md5 hashes. I left a few comments!
migrationMappingPropertyHashes: { | ||
foo: 'someLongHash', | ||
bar: 'anotherLongHash', | ||
baz: '10.3.0', // hashes and versions will NOT coexist (it's either one or the other) |
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.
nit: it's a little funky that migrationMappingPropertyHashes
will no longer contain hashes, but doesn't seem worth the upheaval of changing it and seems like something we need to keep bwc support for anyway.
Don't have a good solution in mind right now other than tracking it for later and adding a comment on wherever this type is defined.
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.
Thinking about it, I think I'll switch to the same property names used on ZDT algorithm: appVersions
and docVersions
. This way, I will not impact the existing hashes field (which will simply be deprecated).
I believe the advantages of doing this are worth it:
- We will not be reusing a property with an outdated / misleading name.
- We will align with the _meta stored by the ZDT algorithm, which could, in the future, facilitate transition from Cloud to Serverless.
- If a migration fails or Kibana fails to start after a migration, and a rollback is performed, the previous version using hashes will still have the hashes field in place. This will prevent the migration logic from picking up ALL types (this could be a costly operation for large customers).
...s/core/saved-objects/core-saved-objects-migration-server-internal/src/core/gen_index_temp.ts
Outdated
Show resolved
Hide resolved
...s/core/saved-objects/core-saved-objects-migration-server-internal/src/core/gen_index_temp.ts
Outdated
Show resolved
Hide resolved
...s/core/saved-objects/core-saved-objects-migration-server-internal/src/core/gen_index_temp.ts
Outdated
Show resolved
Hide resolved
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.
If I understand this correctly: we need to know for sure that this map correctly reflects hashes for the previous 8.x release in order to know we will have "hits" for this md5 hashes. For non-stack releases, to my knowledge this is only serverless, we accept that this static map may have misses? Am I following correctly 😄
If that's true I'd consider naming this file something like 8_13_0_hash_to_version_map.json
since that is the last stack version where we will be storing hashes in migrationMappingPropertyHashes
.
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.
nit: might be worth adding a README.md
explaining the purpose/reason of this file (transitioning off of md5)
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.
Agree to both comments!
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.
For non-stack releases, to my knowledge this is only serverless, we accept that this static map may have misses?
On serverless we use the ZDT algorithm, which uses the mappingVersions
and docVersions
instead of the migrationMappingPropertyHashes
, so this change only impacts cloud and on prem.
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.
nit: might be worth adding a README.md explaining the purpose/reason of this file (transitioning off of md5)
Added a description (now a const
instead of a JSON file).
src/core/server/integration_tests/saved_objects/migrations/group4/v2_md5_to_mv.test.ts
Show resolved
Hide resolved
src/core/server/integration_tests/saved_objects/migrations/group4/v2_md5_to_mv.test.ts
Show resolved
Hide resolved
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.
A few NITs and questions, but the approach looks fine to me
const updatedRootFields = left.updatedTypes.filter((field) => rootFields.includes(field)); | ||
const updatedTypesQuery = Option.fromNullable(buildPickupMappingsQuery(left.updatedTypes)); |
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.
Asking as I'm not sure anymore: Could left.updatedHashes
contain root fields (e.g namespace
and so on) in addition to types previously, and did that change in that PR in left.updatedTypes
?
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.
The modelVersion
logic is currently not including the root fields, so with the PR we're not storing model versions for them in the _meta
.
I have an update on the pipes to preserve existing behavior, and what I propose is to deep compare the mappings objects for the root fields (which are pretty simple). This way, the updated types will handle comparison of SO types through their modelVersions
and comparison of root fields through deep compare of their mappings.
It will emit 2 different Left responses depending on which of them has changed (root_fields_changed
vs types_changed
), which in turn will simplify the logic in model.ts
.
WDYT?
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.
Seems good to me
...saved-objects/core-saved-objects-migration-server-internal/src/core/build_active_mappings.ts
Show resolved
Hide resolved
} | ||
|
||
// If something exists in actual, but is missing in expected, we don't | ||
// care, as it could be a disabled plugin, etc, and keeping stale stuff | ||
// around is better than migrating unecessesarily. | ||
function findChangedProp(actual: any, expected: any) { | ||
return Object.keys(expected).find((k) => actual[k] !== expected[k]); | ||
function findChangedProp(actual: any, expected: any, hashToVersionMap: Record<string, string>) { |
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.
NIT: I know this was there already, but can somehow use something more precise than any
for those parameters?
@@ -39,11 +39,12 @@ import { DocumentMigrator } from './document_migrator'; | |||
import { runZeroDowntimeMigration } from './zdt'; | |||
import { ALLOWED_CONVERT_VERSION } from './kibana_migrator_constants'; | |||
import { runV2Migration } from './run_v2_migration'; | |||
|
|||
import * as HASH_TO_VERSION_MAP from './hash_to_version_map.json'; |
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.
NIT: why is the import * as XXX
required here compared to import XXX from
?
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.
It was not apparently. I have moved it to constants.ts
on @kbn/core-saved-objects-base-server-internal
.
export interface KibanaMigratorOptions { | ||
client: ElasticsearchClient; | ||
typeRegistry: ISavedObjectTypeRegistry; | ||
defaultIndexTypesMap: IndexTypesMap; | ||
hashToVersionMap?: Record<string, string>; |
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.
NIT: I see it defaults to HASH_TO_VERSION_MAP
, but I think I'd still rather have the new parameter not optional, wdyt?
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.
Sounds good to me, we'll be more consistent with similar params that are being passed 👌🏼
packages/core/saved-objects/core-saved-objects-migration-server-internal/src/next.ts
Outdated
Show resolved
Hide resolved
} | ||
|
||
// If something exists in actual, but is missing in expected, we don't | ||
// care, as it could be a disabled plugin, etc, and keeping stale stuff | ||
// around is better than migrating unecessesarily. | ||
function findChangedProp(actual: any, expected: any) { | ||
return Object.keys(expected).find((k) => actual[k] !== expected[k]); | ||
function findChangedProp(actual: any, expected: any, hashToVersionMap: Record<string, string>) { |
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.
Is it possible to tighten the types and remove any
?
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.
(now part of diff_mappings.ts
)
Fixed in the latest updates
interface HashToVersionMapParams { | ||
type: string; | ||
indexHashOrVersion: string; | ||
appVersion: string; |
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.
When a type's metadata isn't available in the index actual[type]
will be undefined so indexHashOrVersion
could also be undefined.
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.
(Now part of compare_mappings.ts
)
Correct, this has been made optional in the latest updates.
appVersion, | ||
hashToVersionMap, | ||
}: HashToVersionMapParams): boolean { | ||
const indexEquivalentVersion = hashToVersionMap[`${type}|${indexHashOrVersion}`]; |
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.
${type}|${indexHashOrVersion}
can type
ever be undefined?
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.
(Now part of compare_mappings.ts
)
type
cannot be undefined, as we loop through the different types from the registry.
On the other hand, indexHashOrVersion
could be undefined (e.g. if it is a new type).
In this scenario, searching for type|undefined
in the map would yield no results, and thus that type would be considered as updated.
db3ff4c
to
8cb7af1
Compare
4223d6a
to
99d8ea8
Compare
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.
LGTM
packages/core/saved-objects/core-saved-objects-base-server-internal/src/constants.ts
Show resolved
Hide resolved
packages/core/saved-objects/core-saved-objects-migration-server-internal/src/model/model.ts
Outdated
Show resolved
Hide resolved
...e/server/integration_tests/saved_objects/migrations/group5/pickup_updated_types_only.test.ts
Show resolved
Hide resolved
b4eebbf
to
cd0e33f
Compare
…appings_addition`s
8ca46c7
to
05fa106
Compare
💚 Build Succeeded
Metrics [docs]Public APIs missing comments
Public APIs missing exports
Unknown metric groupsAPI count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: cc @gsoldevila |
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.
nice work
## Summary Follow-up of #176803 Now that `8.14` has been branched and it is about to be released, we can remove the test that ensures the `HASH_TO_VERSION_MAP` is aligned. This PR also rolls back a few changes on the map that shouldn't have been performed, as they belong to `8.15.0`.
## Summary Follow-up of elastic#176803 Now that `8.14` has been branched and it is about to be released, we can remove the test that ensures the `HASH_TO_VERSION_MAP` is aligned. This PR also rolls back a few changes on the map that shouldn't have been performed, as they belong to `8.15.0`. (cherry picked from commit ed2e59f)
# Backport This will backport the following commits from `main` to `8.14`: - [Kbn 176803 cleanup 8.14 md5 check (#183416)](#183416) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-05-15T09:37:42Z","message":"Kbn 176803 cleanup 8.14 md5 check (#183416)\n\n## Summary\r\n\r\nFollow-up of #176803\r\n\r\nNow that `8.14` has been branched and it is about to be released, we can\r\nremove the test that ensures the `HASH_TO_VERSION_MAP` is aligned.\r\n\r\nThis PR also rolls back a few changes on the map that shouldn't have\r\nbeen performed, as they belong to `8.15.0`.","sha":"ed2e59fea95b39dcc853f948ce122544515370f0","branchLabelMapping":{"^v8.15.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Core","release_note:skip","backport:prev-minor","Feature:FIPS","v8.15.0"],"title":"Kbn 176803 cleanup 8.14 md5 check","number":183416,"url":"https://github.com/elastic/kibana/pull/183416","mergeCommit":{"message":"Kbn 176803 cleanup 8.14 md5 check (#183416)\n\n## Summary\r\n\r\nFollow-up of #176803\r\n\r\nNow that `8.14` has been branched and it is about to be released, we can\r\nremove the test that ensures the `HASH_TO_VERSION_MAP` is aligned.\r\n\r\nThis PR also rolls back a few changes on the map that shouldn't have\r\nbeen performed, as they belong to `8.15.0`.","sha":"ed2e59fea95b39dcc853f948ce122544515370f0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v8.15.0","branchLabelMappingKey":"^v8.15.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/183416","number":183416,"mergeCommit":{"message":"Kbn 176803 cleanup 8.14 md5 check (#183416)\n\n## Summary\r\n\r\nFollow-up of #176803\r\n\r\nNow that `8.14` has been branched and it is about to be released, we can\r\nremove the test that ensures the `HASH_TO_VERSION_MAP` is aligned.\r\n\r\nThis PR also rolls back a few changes on the map that shouldn't have\r\nbeen performed, as they belong to `8.15.0`.","sha":"ed2e59fea95b39dcc853f948ce122544515370f0"}}]}] BACKPORT--> Co-authored-by: Gerard Soldevila <[email protected]>
## Summary Addresses elastic/elastic-entity-model#70 Fixes regression introduced in #176803
## Summary Addresses elastic/elastic-entity-model#70 Fixes regression introduced in elastic#176803 (cherry picked from commit 8de3636)
…197573) # Backport This will backport the following commits from `main` to `8.16`: - [Update mappings if/when new SO types are introduced (#197061)](#197061) <!--- Backport version: 9.4.3 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-24T08:21:43Z","message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:Core","release_note:skip","v9.0.0","backport:prev-minor","backport:prev-major","v8.16.0","v8.15.3"],"title":"Update mappings if/when new SO types are introduced","number":197061,"url":"https://github.com/elastic/kibana/pull/197061","mergeCommit":{"message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d"}},"sourceBranch":"main","suggestedTargetBranches":["8.16","8.15"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197061","number":197061,"mergeCommit":{"message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d"}},{"branch":"8.16","label":"v8.16.0","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"},{"branch":"8.15","label":"v8.15.3","branchLabelMappingKey":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Gerard Soldevila <[email protected]>
## Summary Addresses elastic/elastic-entity-model#70 Fixes regression introduced in elastic#176803 (cherry picked from commit 8de3636) # Conflicts: # src/core/server/integration_tests/saved_objects/migrations/group1/v2_migration.test.ts # src/core/server/integration_tests/saved_objects/migrations/group2/multiple_kb_nodes.test.ts # src/core/server/integration_tests/saved_objects/migrations/kibana_migrator_test_kit.fixtures.ts
## Summary Addresses elastic/elastic-entity-model#70 Fixes regression introduced in elastic#176803 (cherry picked from commit 8de3636) # Conflicts: # src/core/server/integration_tests/saved_objects/migrations/group1/v2_migration.test.ts
…197598) # Backport This will backport the following commits from `main` to `8.15`: - [Update mappings if/when new SO types are introduced (#197061)](#197061) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-24T08:21:43Z","message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:Core","release_note:skip","v9.0.0","backport:prev-minor","backport:prev-major","v8.16.0","v8.15.3"],"number":197061,"url":"https://github.com/elastic/kibana/pull/197061","mergeCommit":{"message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197061","number":197061,"mergeCommit":{"message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/197573","number":197573,"state":"MERGED","mergeCommit":{"sha":"3687435cb4531b1a0470abf42f69a420e2041cd2","message":"[8.16] Update mappings if/when new SO types are introduced (#197061) (#197573)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.16`:\n- [Update mappings if/when new SO types are introduced\n(#197061)](https://github.com/elastic/kibana/pull/197061)\n\n<!--- Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT [{\"author\":{\"name\":\"Gerard\nSoldevila\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-10-24T08:21:43Z\",\"message\":\"Update\nmappings if/when new SO types are introduced (#197061)\\n\\n##\nSummary\\r\\n\\r\\nAddresses\nhttps://github.com/elastic/elastic-entity-model/issues/70\\r\\nFixes\nregression introduced\nin\\r\\nhttps://github.com//pull/176803\",\"sha\":\"8de3636e43be7c874b2c3457f1496a0fc31f224d\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"bug\",\"Team:Core\",\"release_note:skip\",\"v9.0.0\",\"backport:prev-minor\",\"backport:prev-major\",\"v8.16.0\",\"v8.15.3\"],\"title\":\"Update\nmappings if/when new SO types are\nintroduced\",\"number\":197061,\"url\":\"https://github.com/elastic/kibana/pull/197061\",\"mergeCommit\":{\"message\":\"Update\nmappings if/when new SO types are introduced (#197061)\\n\\n##\nSummary\\r\\n\\r\\nAddresses\nhttps://github.com/elastic/elastic-entity-model/issues/70\\r\\nFixes\nregression introduced\nin\\r\\nhttps://github.com//pull/176803\",\"sha\":\"8de3636e43be7c874b2c3457f1496a0fc31f224d\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.16\",\"8.15\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/197061\",\"number\":197061,\"mergeCommit\":{\"message\":\"Update\nmappings if/when new SO types are introduced (#197061)\\n\\n##\nSummary\\r\\n\\r\\nAddresses\nhttps://github.com/elastic/elastic-entity-model/issues/70\\r\\nFixes\nregression introduced\nin\\r\\nhttps://github.com//pull/176803\",\"sha\":\"8de3636e43be7c874b2c3457f1496a0fc31f224d\"}},{\"branch\":\"8.16\",\"label\":\"v8.16.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"8.15\",\"label\":\"v8.15.3\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by: Gerard Soldevila <[email protected]>"}},{"branch":"8.15","label":"v8.15.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
…197597) # Backport This will backport the following commits from `main` to `8.x`: - [Update mappings if/when new SO types are introduced (#197061)](#197061) <!--- Backport version: 8.9.8 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sqren/backport) <!--BACKPORT [{"author":{"name":"Gerard Soldevila","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-10-24T08:21:43Z","message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d","branchLabelMapping":{"^v9.0.0$":"main","^v8.17.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["bug","Team:Core","release_note:skip","v9.0.0","backport:prev-minor","backport:prev-major","v8.16.0","v8.15.3"],"number":197061,"url":"https://github.com/elastic/kibana/pull/197061","mergeCommit":{"message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d"}},"sourceBranch":"main","suggestedTargetBranches":["8.15"],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","labelRegex":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/197061","number":197061,"mergeCommit":{"message":"Update mappings if/when new SO types are introduced (#197061)\n\n## Summary\r\n\r\nAddresses https://github.com/elastic/elastic-entity-model/issues/70\r\nFixes regression introduced in\r\nhttps://github.com//pull/176803","sha":"8de3636e43be7c874b2c3457f1496a0fc31f224d"}},{"branch":"8.16","label":"v8.16.0","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"url":"https://github.com/elastic/kibana/pull/197573","number":197573,"state":"MERGED","mergeCommit":{"sha":"3687435cb4531b1a0470abf42f69a420e2041cd2","message":"[8.16] Update mappings if/when new SO types are introduced (#197061) (#197573)\n\n# Backport\n\nThis will backport the following commits from `main` to `8.16`:\n- [Update mappings if/when new SO types are introduced\n(#197061)](https://github.com/elastic/kibana/pull/197061)\n\n<!--- Backport version: 9.4.3 -->\n\n### Questions ?\nPlease refer to the [Backport tool\ndocumentation](https://github.com/sqren/backport)\n\n<!--BACKPORT [{\"author\":{\"name\":\"Gerard\nSoldevila\",\"email\":\"[email protected]\"},\"sourceCommit\":{\"committedDate\":\"2024-10-24T08:21:43Z\",\"message\":\"Update\nmappings if/when new SO types are introduced (#197061)\\n\\n##\nSummary\\r\\n\\r\\nAddresses\nhttps://github.com/elastic/elastic-entity-model/issues/70\\r\\nFixes\nregression introduced\nin\\r\\nhttps://github.com//pull/176803\",\"sha\":\"8de3636e43be7c874b2c3457f1496a0fc31f224d\",\"branchLabelMapping\":{\"^v9.0.0$\":\"main\",\"^v8.17.0$\":\"8.x\",\"^v(\\\\d+).(\\\\d+).\\\\d+$\":\"$1.$2\"}},\"sourcePullRequest\":{\"labels\":[\"bug\",\"Team:Core\",\"release_note:skip\",\"v9.0.0\",\"backport:prev-minor\",\"backport:prev-major\",\"v8.16.0\",\"v8.15.3\"],\"title\":\"Update\nmappings if/when new SO types are\nintroduced\",\"number\":197061,\"url\":\"https://github.com/elastic/kibana/pull/197061\",\"mergeCommit\":{\"message\":\"Update\nmappings if/when new SO types are introduced (#197061)\\n\\n##\nSummary\\r\\n\\r\\nAddresses\nhttps://github.com/elastic/elastic-entity-model/issues/70\\r\\nFixes\nregression introduced\nin\\r\\nhttps://github.com//pull/176803\",\"sha\":\"8de3636e43be7c874b2c3457f1496a0fc31f224d\"}},\"sourceBranch\":\"main\",\"suggestedTargetBranches\":[\"8.16\",\"8.15\"],\"targetPullRequestStates\":[{\"branch\":\"main\",\"label\":\"v9.0.0\",\"branchLabelMappingKey\":\"^v9.0.0$\",\"isSourceBranch\":true,\"state\":\"MERGED\",\"url\":\"https://github.com/elastic/kibana/pull/197061\",\"number\":197061,\"mergeCommit\":{\"message\":\"Update\nmappings if/when new SO types are introduced (#197061)\\n\\n##\nSummary\\r\\n\\r\\nAddresses\nhttps://github.com/elastic/elastic-entity-model/issues/70\\r\\nFixes\nregression introduced\nin\\r\\nhttps://github.com//pull/176803\",\"sha\":\"8de3636e43be7c874b2c3457f1496a0fc31f224d\"}},{\"branch\":\"8.16\",\"label\":\"v8.16.0\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"},{\"branch\":\"8.15\",\"label\":\"v8.15.3\",\"branchLabelMappingKey\":\"^v(\\\\d+).(\\\\d+).\\\\d+$\",\"isSourceBranch\":false,\"state\":\"NOT_CREATED\"}]}]\nBACKPORT-->\n\nCo-authored-by: Gerard Soldevila <[email protected]>"}},{"branch":"8.15","label":"v8.15.3","labelRegex":"^v(\\d+).(\\d+).\\d+$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT-->
Summary
Address #169734 .
We're currently storing information about Saved Object types in the
<index>.mapping._meta
.More specifically, we're storing hashes of the mappings of each type, under the
migrationMappingPropertyHashes
property.This allows us to detect which types' mappings have changed, in order to update and pick up changes only for those types.
The problem is that
md5
cannot be used if we want to be FIPS compliant.Thus, the idea is to stop using hashes to track changes in the SO mappings.
Instead, we're going to use the same
modelVersions
introduced by ZDT:Whenever mappings change for a given SO type, the corresponding
modelVersion
will change too, somodelVersions
can be used to determine if mappings have changed.