Skip to content
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

[Migrations] Add support of deferred migrations #153117

Merged
merged 18 commits into from
May 22, 2023
Merged

Conversation

dokmic
Copy link
Contributor

@dokmic dokmic commented Mar 10, 2023

Summary

Resolves #147445.

Checklist

For maintainers

@dokmic dokmic force-pushed the feature/147445 branch 3 times, most recently from c0fb7fe to e66bb7b Compare April 17, 2023 10:47
@dokmic dokmic force-pushed the feature/147445 branch 7 times, most recently from 93151d1 to ca900f7 Compare April 26, 2023 13:08
@dokmic dokmic force-pushed the feature/147445 branch 3 times, most recently from 751a795 to e857f66 Compare May 2, 2023 15:01
@dokmic dokmic marked this pull request as ready for review May 2, 2023 15:01
@dokmic dokmic requested review from a team as code owners May 2, 2023 15:01
@dokmic dokmic force-pushed the feature/147445 branch 2 times, most recently from b338228 to 9ddfc05 Compare May 15, 2023 15:37
Copy link
Contributor

@pgayvallet pgayvallet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@cnasikas cnasikas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ResponseOps changes LTGM!

Copy link
Contributor

@sebelga sebelga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@dokmic
Copy link
Contributor Author

dokmic commented May 17, 2023

@TinaHeiligers @rudolf @pgayvallet I've made some changes in the PR and also updated the documentation. That would be great if you could take another look at the updated files.

@TinaHeiligers TinaHeiligers self-requested a review May 17, 2023 18:05
Copy link
Contributor

@TinaHeiligers TinaHeiligers left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@kibana-ci
Copy link
Collaborator

💚 Build Succeeded

Metrics [docs]

Public APIs missing comments

Total count of every public API that lacks a comment. Target amount is 0. Run node scripts/build_api_docs --plugin [yourplugin] --stats comments for more detailed information.

id before after diff
@kbn/core-saved-objects-migration-server-internal 86 87 +1
@kbn/core-saved-objects-server 115 117 +2
total +3
Unknown metric groups

API count

id before after diff
@kbn/core-saved-objects-migration-server-internal 120 121 +1
@kbn/core-saved-objects-server 525 531 +6
@kbn/core-saved-objects-utils-server 30 36 +6
total +13

ESLint disabled line counts

id before after diff
enterpriseSearch 19 21 +2
securitySolution 400 404 +4
total +6

References to deprecated APIs

id before after diff
@kbn/core-saved-objects-migration-server-internal 28 27 -1

Total ESLint disabled count

id before after diff
enterpriseSearch 20 22 +2
securitySolution 480 484 +4
total +6

History

  • 💔 Build #128649 failed 17ba0ff1cd4fff624d266511ef7d16ccf423cf70
  • 💔 Build #127914 failed 0a79edbd73dc08e76ee2b8aa1e728c6004304685
  • 💔 Build #127886 failed b3382286fe8a1128391b2f6016976df8dd23de19
  • 💔 Build #127244 failed 60887f38db53185f97d3097ee505913e5d2961ab
  • 💔 Build #127214 failed b04b986402633795966e8ddd575b1009f1e8a22d

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@dokmic dokmic merged commit a65cd35 into elastic:main May 22, 2023
@kibanamachine kibanamachine added the backport:skip This commit does not require backporting label May 22, 2023
@dokmic dokmic deleted the feature/147445 branch May 22, 2023 09:17
pgayvallet added a commit that referenced this pull request May 23, 2023
## Summary

Part of #150312
(next steps depend on #153117)

**This PR does two things:**
- introduce the concept of version persistence schema
- adapt the document migrator to support downward migrations for
documents of an higher version.

In the follow-up, we will then update the calls from the SOR to the
document migrator to allow downward conversions when we're using the ZDT
migration algorithm (which requires
#153117 to be merged)

### Model version persistence schema.

*(This is what has also been named 'eviction schema' or 'known fields
schema'.)*

A new `SavedObjectsModelVersion.schemas.backwardConversion` property was
added to the model version definition.

This 'schema' can either be an arbitrary function, or a `schema.object`
from `@kbn/config-schema`

```ts
type SavedObjectModelVersionBackwardConversionSchema<
  InAttrs = unknown,
  OutAttrs = unknown
> = ObjectType | SavedObjectModelVersionBackwardConversionFn<InAttrs, OutAttrs>;
```

When specified for a version, the document's attributes will go thought
this schema during down conversions by the document migrator.

### Adapt the document migrator to support downward migrations for
documents of an higher version.

Add an `allowDowngrade` option to `DocumentMigrator.migrate` and
`KibanaMigrator.migrateDocument`. When this option is set to `true`, the
document migration will accept to 'downgrade' the document if necessary,
instead of throwing an error as done when the option is `false` or
unspecified (which was the only behavior prior to this PR's changes)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
delanni pushed a commit to delanni/kibana that referenced this pull request May 25, 2023
* Add deferred migrations parameter.
* Update outdated documents query to take into account deferred migrations.
* Update outdated documents query to take into account the core migration version.
* Update read operations in the saved objects repository to perform deferred migrations.
delanni pushed a commit to delanni/kibana that referenced this pull request May 25, 2023
)

## Summary

Part of elastic#150312
(next steps depend on elastic#153117)

**This PR does two things:**
- introduce the concept of version persistence schema
- adapt the document migrator to support downward migrations for
documents of an higher version.

In the follow-up, we will then update the calls from the SOR to the
document migrator to allow downward conversions when we're using the ZDT
migration algorithm (which requires
elastic#153117 to be merged)

### Model version persistence schema.

*(This is what has also been named 'eviction schema' or 'known fields
schema'.)*

A new `SavedObjectsModelVersion.schemas.backwardConversion` property was
added to the model version definition.

This 'schema' can either be an arbitrary function, or a `schema.object`
from `@kbn/config-schema`

```ts
type SavedObjectModelVersionBackwardConversionSchema<
  InAttrs = unknown,
  OutAttrs = unknown
> = ObjectType | SavedObjectModelVersionBackwardConversionFn<InAttrs, OutAttrs>;
```

When specified for a version, the document's attributes will go thought
this schema during down conversions by the document migrator.

### Adapt the document migrator to support downward migrations for
documents of an higher version.

Add an `allowDowngrade` option to `DocumentMigrator.migrate` and
`KibanaMigrator.migrateDocument`. When this option is set to `true`, the
document migration will accept to 'downgrade' the document if necessary,
instead of throwing an error as done when the option is `false` or
unspecified (which was the only behavior prior to this PR's changes)

---------

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
@rudolf rudolf added the Epic:ScaleMigrations Scale upgrade migrations to millions of saved objects label Sep 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport:skip This commit does not require backporting Epic:ScaleMigrations Scale upgrade migrations to millions of saved objects Feature:Migrations Feature:Saved Objects release_note:skip Skip the PR/issue when compiling release notes review Team:Core Core services & architecture: plugins, logging, config, saved objects, http, ES client, i18n, etc v8.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Run embeddable migrations on read only