-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Fix running Kibana Platform migrations in development #61325
Conversation
Pinging @elastic/kibana-platform (Team:Platform) |
const cliArgs = this.coreContext.env.cliArgs; | ||
const skipMigrations = cliArgs.optimize || this.config.migration.skip; | ||
const skipMigrations = | ||
this.config.migration.skip || this.coreContext.env.isDevClusterMaster || !pluginsInitialized; |
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.
cliArgs.optimize
was the wrong option to be listening for. This CLI arg is only specified when running kibana to only run the optimizer and then exit. It is not set when running the optimizer in dev. However, in both cases, plugin initialization is disabled which is really the case where we shouldn't run migrations.
const cliArgs = this.coreContext.env.cliArgs; | ||
const skipMigrations = cliArgs.optimize || this.config.migration.skip; | ||
const skipMigrations = | ||
this.config.migration.skip || this.coreContext.env.isDevClusterMaster || !pluginsInitialized; |
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.
is this flag isDevClusterMaster
already used when calculating pluginsInitialized
? https://github.com/elastic/kibana/pull/61325/files#diff-725c498a267472754f01cff2baa3901bR110
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.
No there's a --plugin.initialized
config option that is used (optimizer also specifies this flag)
274f178
to
5f94f86
Compare
I think we may actually be able to drop the @rudolf Are there any cases where we would want to specify one of these but not the other? I did not find any in the codebase. |
We use it for some tests when ES isn't available which would otherwise block migrations, like
Not sure if we can use Edit: realized after a closer look that this specific test doesn't require plugins to be initialized, but the use case is probably still valid |
Just had a look through our existing migrations.skip occurrences: Redundant, can be removed: Line 62 in a2c002d
Can be replaced with plugins.initialize=false
This test spins up ES so not necessary to skip migrations. It might not be necessary to start ES for this test, if that's the case and we want to speed up the test, this would be the only case where skip migrations is useful:
|
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.
Left a comment of some occurrences of migrations.skip
that we could clean up, but doesn't have to block this PR.
I'm opting to keep |
💚 Build SucceededHistory
To update your PR or re-run it, just comment with: |
it('skips KibanaMigrator migrations when pluginsInitialized=false', async () => { | ||
const coreContext = createCoreContext({ skipMigration: false }); | ||
const soService = new SavedObjectsService(coreContext); | ||
|
||
await soService.setup(createSetupDeps()); | ||
await soService.start({}); | ||
await soService.start({ pluginsInitialized: false }); |
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.
Probably low impact, but we now have the config
SO type that is registered by core, not plugins. The type would be usable but not migrated with PR changes.
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.
Probably the correct way to solve is to have the processes that need to run Core only run setup
and extract whatever information they need.
Summary
This solves a problem where migrations were failing in development for saved object types registered by plugins:
This was failing because the migrations were being run in the master dev process where plugins are not initialized, so the migrations were missing for types registered by Kibana Platform plugins.
This change ensures that migrations are only ran on the actual server process where plugins are initialized.
Checklist
Delete any items that are not applicable to this PR.
For maintainers