-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
[Cases] Mark lens migrations as deferred #159291
Conversation
return { | ||
// @ts-expect-error: remove when core changes the types | ||
deferred, | ||
transform: ( |
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.
Same function as before. Just set it to the transform
attribute.
Pinging @elastic/response-ops (Team:ResponseOps) |
Pinging @elastic/response-ops-cases (Feature:Cases) |
|
||
const migratedMarkdown = { ...parsedComment, children: migratedComment }; | ||
return { | ||
// @ts-expect-error: remove when core changes the types |
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.
@rudolf Is it ok to set it as true when needed?
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.
yes, until #152807 is merged there's a caveat: if there's partial updates against this saved object it could cause migrations to run twice (update comment
without updating typeVersion
) or never run (updating typeVersion
without updating comment
).
Looking at https://github.com/elastic/kibana/blob/main/x-pack/plugins/cases/common/api/cases/comment/index.ts#L250C5-L261 it doesn't seem like we allow partial updates?
Otherwise we're blocked on #152807
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.
Yes, this is correct. We do not allow partial updates for comments.
}); | ||
|
||
const migratedMarkdown = { ...parsedComment, children: migratedComment }; | ||
return { |
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.
We now change "normal" lens migrations into deferred ones. This would work, but I think it'd be more explicit if the actual lens migration was also forced to set deferred: true
.
To do this we'd need to handle migrate being migrate: MigrateFunction | SavedObjectMigrationParams
And then do something like:
if(deferred) { // nit: I would call this variable shouldDefer
if(typeof(migrate) == "function" || migrate.deferred === false) { // just for illustration, typescript won't like this
throw new Error("Cases only allows deferred migrations starting in 8.9.0")
}
}
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.
Discussed this with @cnasikas and @stratoula
This would require a small refactor in embeddable migration framework to allow for MigrateFunction | SavedObjectMigrationParams
instead of just MigrateFunction
. While we ultimately want all embeddable migrations to be deferred we're likely going to start moving to a client-side embeddable migration framework soon #158677
So for now we decided we won't force the lens migration to be deferred: true
but only apply that when we migrate the case comments.
|
||
const migratedMarkdown = { ...parsedComment, children: migratedComment }; | ||
return { | ||
// @ts-expect-error: remove when core changes the types |
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.
yes, until #152807 is merged there's a caveat: if there's partial updates against this saved object it could cause migrations to run twice (update comment
without updating typeVersion
) or never run (updating typeVersion
without updating comment
).
Looking at https://github.com/elastic/kibana/blob/main/x-pack/plugins/cases/common/api/cases/comment/index.ts#L250C5-L261 it doesn't seem like we allow partial updates?
Otherwise we're blocked on #152807
x-pack/plugins/cases/server/saved_object_types/migrations/comments.test.ts
Show resolved
Hide resolved
x-pack/plugins/cases/server/saved_object_types/migrations/comments.test.ts
Outdated
Show resolved
Hide resolved
@elasticmachine merge upstream |
💚 Build Succeeded
Metrics [docs]Unknown metric groupsESLint disabled line counts
Total ESLint disabled count
History
To update your PR or re-run it, just comment with: cc @cnasikas |
## Summary In Cases, users can add lens visualizations in a case. The lens's attributes persist inside the `cases-comments` saved object. If the lens team adds a migration a migration will run for the `cases-comments` SOs to migrate any lens visualization inside the case comment. In this PR we defer the lens migrations to be done on read when it is fetched by users. This way, the cases comments will not be migrated at Kibana startup. Blocker for elastic#158468 ### Checklist Delete any items that are not applicable to this PR. - [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 ### For maintainers - [x] This was checked for breaking API changes and was [labeled appropriately](https://www.elastic.co/guide/en/kibana/master/contributing.html#kibana-release-notes-process) --------- Co-authored-by: Kibana Machine <42973632+kibanamachine@users.noreply.github.com>
Summary
In Cases, users can add lens visualizations in a case. The lens's attributes persist inside the
cases-comments
saved object. If the lens team adds a migration a migration will run for thecases-comments
SOs to migrate any lens visualization inside the case comment. In this PR we defer the lens migrations to be done on read when it is fetched by users. This way, the cases comments will not be migrated at Kibana startup.Blocker for #158468
Checklist
Delete any items that are not applicable to this PR.
For maintainers