[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.
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.
@rudolf Is it ok to set it as true when needed?
There was a problem hiding this comment.
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.
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.
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.
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.
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
|
@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-commentssaved object. If the lens team adds a migration a migration will run for thecases-commentsSOs 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