-
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
Support for cross-type Saved Object migration #91143
Comments
Pinging @elastic/kibana-alerting-services (Team:Alerting Services) |
Pinging @elastic/kibana-core (Team:Core) |
One of the reason this won't work today is because changing a document's type requires changing it's raw _id and this isn't possible in v2 migrations. This is the same problem for supporting multi-namespace migrations so it will be addressed as part of #86247 Update: confirmed that #91144 works with v1 migrations
So once #86247 is done the only remaining work would be to add an integration test for renaming types. |
I see #86247 is now closed. Does that mean we can try again to change the SO type via migrations v2? |
Even now that we technically can change an object's id, there are a couple things very challenging if we want to allow type renaming. Outdated documents query and document migrationFirst, if a type is renamed, we'll need to keep track of its previous type(s) to properly handle migration. E.g if a type const myType: SavedObjectType = {
name: 'new',
typeChanges: [
{ version: '7.15.0', previousName: 'old' }
],
migrations: {
'7.13.0': migrateTo7_1_3,
'7.17.0': migrateTo7_1_7
}
} Given that, the document migrator would be able to split the migrations between the old and new type (and to be aware of previously used type names to accept to migrate them) This could be done by either spliting the migrations between the old and new types during We would also need to update the kibana/src/core/server/saved_objects/migrationsv2/model.ts Lines 975 to 984 in 26272fa
Note that we probably want to have #97965 implemented too. Also note that given the complexity of these changes, I'm not very optimistic about being able to support
As having the same name for a renamed type and a newly introduced one seems like a nightmare for both points (outdated query and document migrator implementation). It would probably doable, by having 'new' types specifying the version they were introduced at, and then generating a 'time chart' of the usage of the type name, but it would probably be even more painful than it sounds. Just for the record, the definition could look like: const myType: SavedObjectType = {
name: 'new',
typeChanges: [
{ version: '7.15.0', oldName: 'old' }
],
}
const newOld: SavedObjectType = {
name: 'old',
since: '7.17.0'
} but the complexity isn't probably worth the cost unless this is a hard requirement. References rewriteAnother thing we'll need to address is how to rewrite the references to the renamed type, as if we have our For the SO ImportWe are migrating objects during the import/creation, so I don't think we'll need to do anything here. cc @jportner @mshustov @joshdover do you see anything I may have missed? |
I don't think we would need to do that. The query checks if any documents are outdated, then feeds any outdated documents to the DocumentMigrator to have all appropriate transforms applied.
The way this is designed today, in a given version,
Nothing comes to mind. I agree it should be doable as proposed. I also agree that allowing "Support for reintroduction of type A at a later point" sounds like more trouble than it's worth. |
Correct me if I'm wrong, but I think the query checks if any known document type are outdated, atm. const outdatedDocumentsQuery = {
bool: {
should: Object.entries(migrationVersionPerType).map(([type, latestVersion]) => ({
bool: {
must: { term: { type } },
must_not: { term: { [`migrationVersion.${type}`]: latestVersion } },
},
})),
},
};
👍 |
Ah you're absolutely right, I understand the intent now. Agreed, this would need to be changed. |
@gmmorris is this something that is mandatory to be done before |
Mandatory is a very strong word :) @mikecote, correct me if I'm wrong, but our only issue blocked on this is #100068, am I right? Any thoughts? |
Correct, after speaking with @kobelb, it felt ok to do in a minor so I would no longer say it's needed for 8.0. But hopefully soon so we can address our technical debt with terminology. (especially if we're planning to create another SO as data called "alert" which is currently in use). |
Ok, thanks. Asking because of the interactions with #101351. Ideally, we would still be able to address current issue before |
As part of #144035 we're no longer reindexing documents but instead re-using the same index #147237. Because the type of a saved object is encoded in it's So this adds additional complexity towards achieving this. |
As part of the Alerting Terminology issue we wish to migrate some of our Saved Objects from one type to another.
I spoke to @rudolf and my understanding is that this is supposed to work, but he isn't sure how reliable/sustainable this is as it has never actually been used.
I'm submitting this issue for us to verify whether the existing implementation can support our requirements.
Use Case
At the moment we have three Saved Object types:
alert
(in thealerts
plugin),action
andaction_task_params
(in theactions
plugin).We wish to rename them as part of the terminology update, as it will become very confusing having an
alert
SO type that is used forrule
andaction
which is used forconnector
. There's also a scenario in which we'll need to introduce a SO foralert
(what we current refer to as analert instance
), and that will make things worse as we'd have an alert entity that isn't backed by an alert SO (as our currentalert
SO would be backing the rule entity).For this reason, our requirements are two fold:
type A
totype B
. We would need this to migratealert
torule
as is.type A
at a later point. We would need this to introduce a SO that represents analert
, though we aren't sure we'll actually need this, and worse that happens we can introduce it as a new name such asrule-alert
or something like that.The text was updated successfully, but these errors were encountered: