mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 01:13:23 -04:00
[Obs AI Assistant] Defer KB migration until index assets have been updated (#211523)
Follow-up to https://github.com/elastic/kibana/pull/210386 Closes: https://github.com/elastic/kibana/issues/211525 This ensures that we don't start executing the knowledge base migration until index assets have been updated
This commit is contained in:
parent
e5bd422f6e
commit
4cd9ef318b
2 changed files with 10 additions and 3 deletions
|
@ -130,9 +130,10 @@ export class ObservabilityAIAssistantPlugin
|
|||
}));
|
||||
|
||||
// Update existing index assets (mappings, templates, etc). This will not create assets if they do not exist.
|
||||
updateExistingIndexAssets({ logger: this.logger.get('index_assets'), core }).catch((e) =>
|
||||
this.logger.error(`Index assets could not be updated: ${e.message}`)
|
||||
);
|
||||
const indexAssetsUpdatedPromise = updateExistingIndexAssets({
|
||||
logger: this.logger.get('index_assets'),
|
||||
core,
|
||||
}).catch((e) => this.logger.error(`Index assets could not be updated: ${e.message}`));
|
||||
|
||||
// register task to migrate knowledge base entries to include semantic_text field
|
||||
registerAndScheduleKbSemanticTextMigrationTask({
|
||||
|
@ -140,6 +141,7 @@ export class ObservabilityAIAssistantPlugin
|
|||
taskManager: plugins.taskManager,
|
||||
logger: this.logger.get('kb_semantic_text_migration_task'),
|
||||
config: this.config,
|
||||
indexAssetsUpdatedPromise,
|
||||
}).catch((e) =>
|
||||
this.logger.error(
|
||||
`Knowledge base semantic_text migration task could not be registered: ${e.message}`
|
||||
|
|
|
@ -28,17 +28,22 @@ export async function registerAndScheduleKbSemanticTextMigrationTask({
|
|||
logger,
|
||||
core,
|
||||
config,
|
||||
indexAssetsUpdatedPromise,
|
||||
}: {
|
||||
taskManager: TaskManagerSetupContract;
|
||||
logger: Logger;
|
||||
core: CoreSetup<ObservabilityAIAssistantPluginStartDependencies>;
|
||||
config: ObservabilityAIAssistantConfig;
|
||||
indexAssetsUpdatedPromise: Promise<void>;
|
||||
}) {
|
||||
const [coreStart, pluginsStart] = await core.getStartServices();
|
||||
|
||||
// register task
|
||||
registerKbSemanticTextMigrationTask({ taskManager, logger, coreStart, config });
|
||||
|
||||
// wait for index assets to be updated
|
||||
await indexAssetsUpdatedPromise;
|
||||
|
||||
// schedule task
|
||||
await scheduleKbSemanticTextMigrationTask({ taskManager: pluginsStart.taskManager, logger });
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue