Kibana: Saved Object Migrations fail when a plugin is disabled

Created on 4 Feb 2020  路  3Comments  路  Source: elastic/kibana

When Saved Object migrations run they update the Saved Object with a migrationVersion property like:

migrationVersion: {
  dashboard: '7.1.1',
  space: '6.6.0',
}

However, if a plugin that previously migrated data is later disabled, Saved Object Migrations will throw the following exception and Kibana will refuse to start.

Error: Document "default" has property "space" which belongs to a more recent version of Kibana (6.6.0).
at props.find.p (/usr/share/kibana/src/core/server/saved_objects/migrations/core/document_migrator.js:249:27)n at Array.find

Note: disabling a plugin won't trigger a migration to run. But if there's other objects that are outdated these will trigger the migration to run which will then fail on the disabled plugin's migration.

I.e. disabling the spaces plugin, and running a version of Kibana which has a dashboard migration > 7.1.1 will trigger a migration, and then throw when attempting to migrate the above mentioned document.

This could also happen when importing Saved Objects.

Caused by:
https://github.com/elastic/kibana/blob/85c8232c0b81e9e0dd2265e04b2cc26dffaf1b60/src/core/server/saved_objects/migrations/core/document_migrator.ts#L334-L345

Saved Objects Core bug ResilientSavedObjectMigrations

Most helpful comment

This will probably be fixed by https://github.com/elastic/kibana/pull/78413 since we will no longer read-transform-write every document. Instead we search for outdated documents and only update these, so if a plugin is disabled it's documents will no longer show up as outdated.

All 3 comments

Pinging @elastic/kibana-platform (Team:Platform)

As discussed via slack, we should only use the migrationVersions of type that are known of the migrator. That way a disabled plugin would just not run it's associated migrations until re-enabled.

This will probably be fixed by https://github.com/elastic/kibana/pull/78413 since we will no longer read-transform-write every document. Instead we search for outdated documents and only update these, so if a plugin is disabled it's documents will no longer show up as outdated.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

stacey-gammon picture stacey-gammon  路  3Comments

celesteking picture celesteking  路  3Comments

spalger picture spalger  路  3Comments

MaartenUreel picture MaartenUreel  路  3Comments

LukeMathWalker picture LukeMathWalker  路  3Comments